annotate src/iris/iris.c @ 116:a578bf9b2851 trunk

[svn] - iris vis plugin port
author nenolod
date Tue, 24 Oct 2006 21:25:31 -0700
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
116
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
1 /* Iris - visualization plugin for XMMS
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
2 * Copyright (C) 2000-2002 Cédric DELFOSSE (cdelfosse@free.fr)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
3 *
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
4 * This program is free software; you can redistribute it and/or modify
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
7 * (at your option) any later version.
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
8 *
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
9 * This program is distributed in the hope that it will be useful,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
12 * GNU General Public License for more details.
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
13 *
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
15 * along with this program; if not, write to the Free Software
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
17 */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
18
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
19 #include "config.h"
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
20
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
21 #include <X11/Xlib.h>
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
22 #include <X11/keysym.h>
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
23 #include <gtk/gtk.h>
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
24 #include <math.h>
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
25
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
26 #include <GL/gl.h>
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
27 #include <GL/glx.h>
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
28 #include <X11/extensions/xf86vmode.h>
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
29 #include <pthread.h>
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
30 #ifdef HAVE_SCHED_SETSCHEDULER
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
31 #include <sched.h>
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
32 #endif
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
33 #include <stdlib.h>
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
34 #include <sys/time.h>
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
35 #include <unistd.h>
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
36
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
37 #include <audacious/plugin.h>
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
38 #include <audacious/util.h>
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
39 #include <audacious/beepctrl.h>
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
40 #include <audacious/configdb.h>
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
41 #include "iris.h"
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
42
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
43 #define BEAT_MAX 100
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
44
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
45 GLfloat y_angle = 45.0, y_speed = 0.5;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
46 GLfloat x_angle = 20.0, x_speed = 0.0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
47 GLfloat z_angle = 0.0, z_speed = 0.0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
48 static GLfloat scale;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
49 static GLfloat x_angle_wanted;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
50
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
51 GLWindow GLWin;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
52
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
53 /* attributes for a single buffered visual in RGBA format with at least
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
54 * 4 bits per color and a 16 bit depth buffer */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
55 static int attrListSgl[] = { GLX_RGBA, GLX_RED_SIZE, 4,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
56 GLX_GREEN_SIZE, 4,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
57 GLX_BLUE_SIZE, 4,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
58 GLX_DEPTH_SIZE, 16,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
59 None
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
60 };
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
61
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
62 /* attributes for a double buffered visual in RGBA format with at least
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
63 * 4 bits per color and a 16 bit depth buffer */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
64 static int attrListDbl[] = { GLX_RGBA, GLX_DOUBLEBUFFER,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
65 GLX_RED_SIZE, 4,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
66 GLX_GREEN_SIZE, 4,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
67 GLX_BLUE_SIZE, 4,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
68 GLX_DEPTH_SIZE, 16,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
69 None
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
70 };
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
71
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
72 static gboolean going = FALSE;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
73 static gboolean initialized = FALSE;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
74 static gboolean grabbed_pointer = FALSE, firsttime = TRUE;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
75 static Atom wmDelete;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
76 static pthread_t draw_thread;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
77
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
78 datas_t datas;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
79
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
80 static int num_bands = NUM_BANDS;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
81 static int beat = 0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
82
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
83 unsigned int transition_frames = 0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
84 unsigned int max_transition_frames = 0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
85
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
86 static void iris_init (void);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
87 static void iris_cleanup (void);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
88 static void iris_about (void);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
89 static void iris_playback_start (void);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
90 static void iris_playback_stop (void);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
91 static void iris_render_freq (gint16 data[][256]);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
92
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
93 static float dps = 0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
94
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
95 gint beat_before = -1;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
96
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
97 extern iris_config newconfig;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
98
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
99 VisPlugin iris_vp = {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
100 NULL,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
101 NULL,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
102 0,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
103 NULL, /* Description */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
104 0,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
105 1,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
106 iris_init, /* init */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
107 iris_cleanup, /* cleanup */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
108 iris_about, /* about */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
109 iris_configure, /* configure */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
110 NULL, /* disable_plugin */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
111 iris_playback_start, /* playback_start */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
112 iris_playback_stop, /* playback_stop */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
113 NULL, /* render_pcm */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
114 iris_render_freq /* render_freq */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
115 };
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
116
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
117
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
118 void
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
119 about_close_clicked (GtkWidget * w, GtkWidget ** window)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
120 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
121 gtk_widget_destroy (*window);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
122 *window = NULL;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
123 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
124
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
125
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
126 void
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
127 about_closed (GtkWidget * w, GdkEvent * e, GtkWidget ** window)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
128 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
129 about_close_clicked (w, window);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
130 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
131
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
132
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
133 static void
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
134 iris_about (void)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
135 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
136 static GtkWidget *window_about = NULL;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
137 GtkWidget *vbox, *button, *close, *label;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
138
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
139 if (window_about)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
140 return;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
141
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
142 window_about = gtk_window_new (GTK_WINDOW_TOPLEVEL);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
143 gtk_window_set_title (GTK_WINDOW (window_about), "About IRIS plugin");
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
144 gtk_window_set_policy (GTK_WINDOW (window_about), FALSE, FALSE, FALSE);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
145 gtk_window_set_position (GTK_WINDOW (window_about), GTK_WIN_POS_MOUSE);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
146 vbox = gtk_vbox_new (FALSE, 4);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
147 gtk_container_add (GTK_CONTAINER (window_about), vbox);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
148 gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
149 gtk_widget_show (vbox);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
150
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
151 label = gtk_label_new ("\n\
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
152 Iris XMMS Plugin.\n\
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
153 Copyright (C) 2001-2003, Cédric Delfosse.\n\
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
154 \n\
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
155 Email: <cdelfosse@free.fr> \n\
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
156 Homepage: <http://cdelfosse.free.fr/xmms-iris/>\n\
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
157 Development: <http://savannah.gnu.org/projects/iris/>\n\
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
158 \n\
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
159 Authors:\n\
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
160 Cédric Delfosse\n\
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
161 Marinus Schraal\n\
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
162 Ron Lockwood-Childs\n\
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
163 Ported to Audacious by Arthur Taylor\n\
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
164 \n\
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
165 This program is free software; you can redistribute it and/or modify\n\
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
166 it under the terms of the GNU General Public License as published by\n\
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
167 the Free Software Foundation; either version 2 of the License, or\n\
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
168 (at your option) any later version.\n\
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
169 \n\
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
170 This program is distributed in the hope that it will be useful,\n\
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
171 but WITHOUT ANY WARRANTY; without even the implied warranty of\n\
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
172 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
173 GNU General Public License for more details.\n\
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
174 \n\
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
175 You should have received a copy of the GNU General Public License\n\
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
176 along with this program; if not, write to the Free Software\n\
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
177 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307\n\
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
178 USA");
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
179 gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 8);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
180 gtk_widget_show (label);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
181
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
182 button = gtk_hbutton_box_new ();
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
183 gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 8);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
184 gtk_widget_show (button);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
185
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
186 close = gtk_button_new_with_label ("Close");
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
187 GTK_WIDGET_SET_FLAGS (close, GTK_CAN_DEFAULT);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
188 gtk_window_set_default (GTK_WINDOW (window_about), close);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
189 gtk_hbutton_box_set_layout_default (GTK_BUTTONBOX_END);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
190 gtk_box_pack_end (GTK_BOX (button), close, FALSE, FALSE, 8);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
191 gtk_widget_show (close);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
192
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
193 gtk_signal_connect (GTK_OBJECT (close), "clicked",
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
194 GTK_SIGNAL_FUNC (about_close_clicked), &window_about);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
195 gtk_signal_connect (GTK_OBJECT (window_about), "delete-event",
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
196 GTK_SIGNAL_FUNC (about_closed), &window_about);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
197
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
198 gtk_widget_show (window_about);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
199 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
200
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
201
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
202 /* Creates an empty cursor icon for when hovering over our window content */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
203 void
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
204 hide_cursor ()
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
205 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
206 Cursor no_ptr;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
207 Pixmap bm_no;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
208 Colormap cmap;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
209 XColor black, dummy;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
210
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
211 static unsigned char bm_no_data[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
212
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
213 cmap = DefaultColormap (GLWin.dpy, DefaultScreen (GLWin.dpy));
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
214 XAllocNamedColor (GLWin.dpy, cmap, "black", &black, &dummy);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
215 bm_no = XCreateBitmapFromData (GLWin.dpy, GLWin.window, bm_no_data, 8, 8);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
216 no_ptr =
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
217 XCreatePixmapCursor (GLWin.dpy, bm_no, bm_no, &black, &black, 0, 0);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
218 XDefineCursor (GLWin.dpy, GLWin.window, no_ptr);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
219 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
220
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
221
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
222 /* this function creates our window and sets it up properly */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
223 static Window
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
224 create_window (char *title)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
225 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
226 XVisualInfo *vi;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
227 int i;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
228
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
229 /* get a connection */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
230 GLWin.dpy = XOpenDisplay (0);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
231 if (GLWin.dpy == NULL)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
232 g_log (NULL, G_LOG_LEVEL_CRITICAL,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
233 __FILE__ ": XOpenDisplay returns NULL");
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
234 GLWin.screen = DefaultScreen (GLWin.dpy);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
235
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
236 /* get an appropriate visual */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
237 vi = glXChooseVisual (GLWin.dpy, GLWin.screen, attrListDbl);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
238 if (vi == NULL)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
239 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
240 vi = glXChooseVisual (GLWin.dpy, GLWin.screen, attrListSgl);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
241 GLWin.DoubleBuffered = 0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
242 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
243 else
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
244 GLWin.DoubleBuffered = 1;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
245
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
246 if (vi == NULL)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
247 g_log (NULL, G_LOG_LEVEL_CRITICAL,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
248 __FILE__ ": glXChooseVisual returns NULL");
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
249
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
250 glXQueryVersion (GLWin.dpy, &GLWin.glxMajorVersion, &GLWin.glxMinorVersion);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
251 /* create a GLX context */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
252 GLWin.ctx = glXCreateContext (GLWin.dpy, vi, 0, GL_TRUE);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
253 if (GLWin.ctx == NULL)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
254 g_log (NULL, G_LOG_LEVEL_CRITICAL,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
255 __FILE__ ": glXCreateContext can\'t create a rendering context");
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
256
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
257 /* create a color map */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
258 GLWin.attr.colormap =
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
259 XCreateColormap (GLWin.dpy, RootWindow (GLWin.dpy, vi->screen),
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
260 vi->visual, AllocNone);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
261 GLWin.attr.border_pixel = 0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
262
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
263 if ((config.fullscreen && firsttime) || GLWin.fs)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
264 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
265 int bestMode = 0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
266
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
267 GLWin.fs = True;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
268 GLWin.fs_width = config.fs_width;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
269 GLWin.fs_height = config.fs_height;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
270 /* look for mode with requested resolution */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
271 for (i = 0; i < GLWin.modeNum; i++)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
272 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
273 if ((GLWin.modes[i]->hdisplay == GLWin.fs_width)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
274 && (GLWin.modes[i]->vdisplay == GLWin.fs_height))
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
275 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
276 bestMode = i;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
277 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
278 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
279 XF86VidModeSwitchToMode (GLWin.dpy, GLWin.screen,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
280 GLWin.modes[bestMode]);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
281 XF86VidModeSetViewPort (GLWin.dpy, GLWin.screen, 0, 0);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
282 GLWin.fs_width = GLWin.modes[bestMode]->hdisplay;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
283 GLWin.fs_height = GLWin.modes[bestMode]->vdisplay;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
284
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
285 /* create a fullscreen window */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
286 GLWin.attr.override_redirect = True;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
287 GLWin.attr.event_mask =
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
288 ExposureMask | KeyPressMask | ButtonPressMask | StructureNotifyMask;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
289 GLWin.window =
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
290 XCreateWindow (GLWin.dpy,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
291 RootWindow (GLWin.dpy, vi->screen), 0,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
292 0, GLWin.fs_width, GLWin.fs_height, 0, vi->depth,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
293 InputOutput, vi->visual,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
294 CWBorderPixel | CWColormap |
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
295 CWEventMask | CWOverrideRedirect, &GLWin.attr);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
296 XWarpPointer (GLWin.dpy, None, GLWin.window, 0, 0, 0, 0, 0, 0);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
297 XMapRaised (GLWin.dpy, GLWin.window);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
298 XGrabKeyboard (GLWin.dpy, GLWin.window, True, GrabModeAsync,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
299 GrabModeAsync, CurrentTime);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
300 XGrabPointer (GLWin.dpy, GLWin.window, True, ButtonPressMask,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
301 GrabModeAsync, GrabModeAsync, GLWin.window,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
302 FALSE, CurrentTime);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
303 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
304 else
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
305 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
306 XClassHint xclasshint={"xmms","visplugin"};
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
307 GLWin.window_width = config.window_width;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
308 GLWin.window_height = config.window_height;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
309 /* needed if those aren't set yet - ideally need a way to get the default values for these */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
310 if (config.window_height == 0 || config.window_width == 0)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
311 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
312 config.window_width = 640;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
313 config.window_height = 480;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
314 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
315
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
316 /* create a window in window mode */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
317 GLWin.attr.event_mask =
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
318 ExposureMask | KeyPressMask | ButtonPressMask | StructureNotifyMask;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
319 GLWin.window =
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
320 XCreateWindow (GLWin.dpy,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
321 RootWindow (GLWin.dpy, vi->screen), 0,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
322 0, GLWin.window_width, GLWin.window_height, 0,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
323 vi->depth, InputOutput, vi->visual,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
324 CWBorderPixel | CWColormap | CWEventMask, &GLWin.attr);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
325 XmbSetWMProperties(GLWin.dpy, GLWin.window, "iris","iris", NULL, 0, NULL, NULL, &xclasshint);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
326
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
327 /* only set window title and handle wm_delete_events if in windowed mode */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
328 wmDelete = XInternAtom (GLWin.dpy, "WM_DELETE_WINDOW", True);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
329 XSetWMProtocols (GLWin.dpy, GLWin.window, &wmDelete, 1);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
330 XSetStandardProperties (GLWin.dpy, GLWin.window, title,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
331 title, None, NULL, 0, NULL);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
332 XMapRaised (GLWin.dpy, GLWin.window);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
333 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
334 /* connect the glx-context to the window */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
335 if (!glXMakeCurrent (GLWin.dpy, GLWin.window, GLWin.ctx))
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
336 g_log (NULL, G_LOG_LEVEL_CRITICAL,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
337 __FILE__ ": glXMakeCurrent returns an error");
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
338 if (glXIsDirect (GLWin.dpy, GLWin.ctx))
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
339 GLWin.DRI = 1;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
340
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
341 hide_cursor ();
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
342
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
343 XFree (vi);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
344 firsttime = FALSE;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
345 return GLWin.window;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
346 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
347
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
348
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
349 VisPlugin *
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
350 get_vplugin_info (void)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
351 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
352 iris_vp.description = g_strdup_printf ("iris 3D analyzer %s", VERSION);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
353 return &iris_vp;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
354 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
355
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
356
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
357 static int
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
358 detect_beat (gint32 loudness)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
359 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
360 static gint32 aged; /* smoothed out oudness */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
361 static gint32 lowest; /* quietest point in current beat */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
362 static int elapsed; /* frames since last beat */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
363 static int isquiet; /* was previous frame quiet */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
364 int detected_beat;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
365
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
366 /* Incorporate the current loudness into history */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
367 aged = (aged * 7 + loudness) >> 3;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
368 elapsed++;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
369
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
370 /* If silent, then clobber the beat */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
371 if (aged < 2000 || elapsed > BEAT_MAX)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
372 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
373 elapsed = 0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
374 lowest = aged;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
375 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
376 else if (aged < lowest)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
377 lowest = aged;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
378
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
379 /* Beats are detected by looking for a sudden loudness after a lull.
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
380 * They are also limited to occur no more than once every 15 frames,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
381 * so the beat flashes don't get too annoying.
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
382 */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
383 detected_beat = (loudness * 4 > aged * 3 && aged * 2 > lowest * 3
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
384 && elapsed > 15);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
385 if (detected_beat)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
386 lowest = aged, elapsed = 0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
387
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
388 /* Silence is computed from the aged loudness. The quietref value is
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
389 * set to TRUE only at the start of silence, not throughout the silent
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
390 * period. Also, there is some hysteresis so that silence followed
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
391 * by a slight noise and more silence won't count as two silent
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
392 * periods -- that sort of thing happens during many fade edits, so
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
393 * we have to account for it.
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
394 */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
395 if (aged < (isquiet ? 1500 : 500))
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
396 /* Quiet now -- is this the start of quiet? */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
397 isquiet = TRUE;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
398 else
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
399 isquiet = FALSE;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
400
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
401 /* return the result */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
402 return detected_beat;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
403 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
404
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
405
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
406 /* limit_rotation_speed keep rotation speed to at least dps_config
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
407 by second */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
408 static void
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
409 limit_rotation_speed (gboolean init)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
410 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
411 static struct timeval tv_past;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
412 struct timezone tz;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
413 struct timeval tv_now;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
414 float dps_config = 15;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
415
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
416 if (!init)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
417 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
418 long t;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
419
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
420 gettimeofday (&tv_now, &tz);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
421 t =
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
422 (tv_now.tv_sec - tv_past.tv_sec) * 10000000 + (tv_now.tv_usec -
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
423 tv_past.tv_usec);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
424 dps = y_speed * ((float) 1000000 / (float) t);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
425 if (dps >= (float) dps_config)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
426 y_speed -= 0.02;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
427 else
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
428 y_speed += 0.02;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
429
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
430 memcpy (&tv_past, &tv_now, sizeof (struct timeval));
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
431 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
432 else
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
433 gettimeofday (&tv_past, &tz);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
434 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
435
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
436
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
437 /* limit_fps tries to keep the number of
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
438 frame per seconds to config.fps */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
439 static void
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
440 limit_fps (gboolean init)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
441 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
442 static float fps = 0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
443 static struct timeval tv_past;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
444 struct timezone tz;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
445 struct timeval tv_now;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
446 static int usec = 0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
447
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
448 if (init)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
449 gettimeofday (&tv_past, &tz);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
450 else
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
451 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
452 long t;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
453
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
454 gettimeofday (&tv_now, &tz);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
455 t =
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
456 (tv_now.tv_sec - tv_past.tv_sec) * 10000000 + (tv_now.tv_usec -
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
457 tv_past.tv_usec);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
458 fps = (float) 1000000 / (float) t;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
459
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
460 if (fps >= (float) config.fps)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
461 usec += 100;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
462 else
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
463 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
464 if (usec > 0)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
465 usec -= 100;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
466 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
467 xmms_usleep (usec);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
468 memcpy (&tv_past, &tv_now, sizeof (struct timeval));
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
469 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
470 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
471
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
472 static void
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
473 init_general_draw_mode (int num)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
474 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
475 int transparency;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
476 int wireframe;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
477
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
478 if (theme[num].config->global->transparency != -1)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
479 transparency = theme[num].config->global->transparency;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
480 else
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
481 transparency = (int) (2.0 * rand () / (RAND_MAX + 1.0));
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
482
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
483 if (theme[num].config->global->wireframe != -1)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
484 wireframe = theme[num].config->global->wireframe;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
485 else
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
486 wireframe = (int) (2.0 * rand () / (RAND_MAX + 1.0));
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
487
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
488 if (transparency)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
489 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
490 if (!glIsEnabled (GL_BLEND))
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
491 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
492 glBlendFunc (GL_SRC_ALPHA, GL_ONE);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
493 glEnable (GL_BLEND);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
494 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
495 glDisable (GL_DEPTH_TEST);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
496 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
497 else
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
498 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
499 if (glIsEnabled (GL_BLEND))
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
500 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
501 glDisable (GL_BLEND);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
502 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
503 glEnable (GL_DEPTH_TEST);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
504 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
505
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
506 if (wireframe)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
507 glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
508 else
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
509 glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
510
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
511 if (glIsEnabled(GL_TEXTURE_2D))
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
512 glDisable(GL_TEXTURE_2D);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
513 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
514
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
515
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
516 static int
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
517 compute_theme ()
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
518 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
519 gfloat f_rand, f;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
520 gint i;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
521
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
522 for (i = 0, f_rand = 0.0; i < THEME_NUMBER; i++)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
523 f_rand += theme[i].config->global->priority;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
524 f_rand = f_rand * rand () / (RAND_MAX + 1.0);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
525
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
526 i = 0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
527 f = 0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
528 while (i < THEME_NUMBER)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
529 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
530 gfloat f_theme;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
531 f_theme = theme[i].config->global->priority;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
532 if (f_theme)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
533 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
534 f += f_theme;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
535 if (f_rand < f)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
536 break;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
537 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
538 i++;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
539 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
540
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
541 if (!f)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
542 return (int) ((gfloat) THEME_NUMBER * rand () / (RAND_MAX + 1.0));
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
543 else
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
544 return i;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
545 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
546
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
547
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
548 static int
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
549 choose_theme (gboolean init)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
550 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
551 static long sec_btw_theme = 10 * 10000000;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
552 static struct timeval tv_past;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
553 struct timezone tz;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
554 struct timeval tv_now;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
555 static int th, th_tmp;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
556
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
557 if (!init)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
558 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
559 long t;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
560
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
561 gettimeofday (&tv_now, &tz);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
562 t =
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
563 (tv_now.tv_sec - tv_past.tv_sec) * 10000000 + (tv_now.tv_usec -
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
564 tv_past.tv_usec);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
565 if ((t > sec_btw_theme) || (beat && config.change_theme_on_beat))
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
566 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
567 /* we come here if:
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
568 - time for the theme is expired
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
569 - a beat is detected and the change_theme_on_beat option is on
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
570 */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
571 if (config.transition)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
572 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
573 if (transition_frames == 0)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
574 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
575 th_tmp = compute_theme ();
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
576 if (th != th_tmp)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
577 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
578 transition_frames =
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
579 (unsigned int) config.fps * config.trans_duration /
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
580 10;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
581 max_transition_frames = transition_frames;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
582 memcpy (&tv_past, &tv_now, sizeof (struct timeval));
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
583 init_theme_transition (transition_frames,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
584 max_transition_frames);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
585 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
586 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
587 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
588 else
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
589 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
590 th = compute_theme ();
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
591 init_general_draw_mode (th);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
592 if (theme[th].init_draw_mode != NULL)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
593 theme[th].init_draw_mode ();
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
594 memcpy (&tv_past, &tv_now, sizeof (struct timeval));
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
595 x_angle_wanted = theme[th].get_x_angle ();
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
596 x_speed = copysign (0.08, x_angle_wanted - x_angle);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
597 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
598 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
599 /* change theme after half of the set frames have passed */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
600 else if ((((int) max_transition_frames / 2) == transition_frames)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
601 && config.transition && (transition_frames != 0))
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
602 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
603 th = th_tmp;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
604 init_general_draw_mode (th);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
605 if (theme[th].init_draw_mode != NULL)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
606 theme[th].init_draw_mode ();
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
607 x_angle_wanted = theme[th].get_x_angle ();
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
608 x_speed = copysign (0.08, x_angle_wanted - x_angle);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
609 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
610 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
611 else
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
612 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
613 /* the first time choose_theme is called,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
614 tv_past is initialized */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
615 gettimeofday (&tv_past, &tz);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
616 th = compute_theme ();
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
617 init_general_draw_mode (th);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
618 if (theme[th].init_draw_mode != NULL)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
619 theme[th].init_draw_mode ();
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
620 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
621
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
622 return (th);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
623 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
624
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
625
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
626 static void
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
627 draw_iris (void)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
628 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
629 int th;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
630
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
631 limit_fps (FALSE);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
632 th = choose_theme (FALSE);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
633
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
634 if ((config.color_beat) && (beat_before > 0))
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
635 glClearColor (config.color_flash_red, config.color_flash_green,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
636 config.color_flash_blue, 1);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
637 else
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
638 glClearColor (config.bgc_red, config.bgc_green, config.bgc_blue, 1);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
639 glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
640
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
641 glPushMatrix ();
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
642 glTranslatef (0.0, -0.5, -7.0);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
643 glRotatef (x_angle, 1.0, 0.0, 0.0);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
644 glRotatef (y_angle, 0.0, 1.0, 0.0);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
645 glRotatef (z_angle, 0.0, 0.0, 1.0);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
646
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
647 if (transition_frames > 0 && config.transition)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
648 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
649 theme_transition ();
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
650 transition_frames--;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
651 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
652
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
653 theme[th].draw_one_frame (beat);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
654
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
655 glEnd ();
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
656 glPopMatrix ();
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
657
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
658 glXSwapBuffers (GLWin.dpy, GLWin.window);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
659 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
660
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
661
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
662 static gint
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
663 disable_func (gpointer data)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
664 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
665 iris_vp.disable_plugin (&iris_vp);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
666 return FALSE;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
667 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
668
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
669
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
670 GLvoid
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
671 init_gl (GLvoid)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
672 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
673 glMatrixMode (GL_PROJECTION);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
674 glLoadIdentity ();
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
675 glFrustum (-1, 1, -1.5, 1, 1.5, 12);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
676 glMatrixMode (GL_MODELVIEW);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
677 glLoadIdentity ();
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
678 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
679
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
680
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
681 GLvoid
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
682 kill_gl_window (GLvoid)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
683 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
684 if (GLWin.ctx)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
685 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
686 glXMakeCurrent (GLWin.dpy, None, NULL);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
687 glXDestroyContext (GLWin.dpy, GLWin.ctx);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
688 GLWin.ctx = NULL;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
689 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
690 /* switch back to original desktop resolution if we were in fs */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
691 if (GLWin.fs)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
692 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
693 XF86VidModeSwitchToMode (GLWin.dpy, GLWin.screen, &GLWin.deskMode);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
694 XF86VidModeSetViewPort (GLWin.dpy, GLWin.screen, 0, 0);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
695 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
696 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
697
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
698
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
699 void *
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
700 draw_thread_func (void *arg)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
701 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
702 Bool configured = FALSE;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
703
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
704 g_log (NULL, G_LOG_LEVEL_DEBUG, __FILE__ ": draw_thread_func: Starting.");
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
705
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
706 if ((GLWin.window = create_window ("Iris")) == 0)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
707 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
708 g_log (NULL, G_LOG_LEVEL_CRITICAL,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
709 __FILE__ ": unable to create window");
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
710 pthread_exit (NULL);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
711 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
712
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
713 init_gl ();
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
714 choose_theme (TRUE);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
715
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
716
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
717 #ifdef HAVE_SCHED_SETSCHEDULER
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
718 if (xmms_check_realtime_priority ())
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
719 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
720 struct sched_param sparam;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
721 sparam.sched_priority = sched_get_priority_max (SCHED_OTHER);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
722 pthread_setschedparam (pthread_self (), SCHED_OTHER, &sparam);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
723 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
724 #endif
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
725
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
726 while (going) /* plugin enabled */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
727 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
728 while (XPending (GLWin.dpy))
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
729 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
730 XEvent event;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
731 KeySym keysym;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
732 char buf[16];
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
733
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
734 XNextEvent (GLWin.dpy, &event);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
735 switch (event.type)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
736 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
737 case Expose:
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
738 if (event.xexpose.count != 0)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
739 break;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
740 configured = TRUE;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
741 break;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
742 case ConfigureNotify:
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
743 glViewport (0, 0, event.xconfigure.width,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
744 event.xconfigure.height);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
745 configured = TRUE;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
746 break;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
747 case KeyPress:
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
748
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
749 XLookupString (&event.xkey, buf, 16, &keysym, NULL);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
750 switch (keysym)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
751 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
752 case XK_Escape:
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
753
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
754 /* Ugly hack to get the disable_plugin call in the main thread. */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
755 GDK_THREADS_ENTER ();
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
756 gtk_idle_add (disable_func, NULL);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
757 GDK_THREADS_LEAVE ();
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
758 break;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
759 case XK_z:
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
760 xmms_remote_playlist_prev (iris_vp.xmms_session);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
761 break;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
762 case XK_x:
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
763 xmms_remote_play (iris_vp.xmms_session);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
764 break;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
765 case XK_c:
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
766 xmms_remote_pause (iris_vp.xmms_session);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
767 break;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
768 case XK_v:
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
769 xmms_remote_stop (iris_vp.xmms_session);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
770 break;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
771 case XK_b:
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
772 xmms_remote_playlist_next (iris_vp.xmms_session);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
773 break;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
774 case XK_Left:
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
775 y_speed -= 0.1;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
776 if (y_speed < -3.0)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
777 y_speed = -3.0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
778 break;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
779 case XK_Right:
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
780 y_speed += 0.1;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
781 if (y_speed > 3.0)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
782 y_speed = 3.0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
783 break;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
784 case XK_Return:
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
785 x_speed = 0.0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
786 y_speed = 0.3;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
787 z_speed = 0.0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
788 x_angle = 70.0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
789 y_angle = 45.0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
790 z_angle = 0.0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
791 break;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
792 case XK_Tab:
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
793 iris_configure ();
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
794 break;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
795 case XK_f:
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
796 //iris_save_window_attributes ();
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
797 kill_gl_window ();
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
798 XCloseDisplay (GLWin.dpy);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
799 GLWin.fs = !GLWin.fs;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
800 create_window ("Iris");
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
801 init_gl ();
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
802 choose_theme (TRUE);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
803 break;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
804 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
805
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
806 break;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
807 case ClientMessage:
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
808 if ((Atom) event.xclient.data.l[0] == wmDelete)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
809 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
810 GDK_THREADS_ENTER ();
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
811 gtk_idle_add (disable_func, NULL);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
812 GDK_THREADS_LEAVE ();
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
813 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
814 break;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
815 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
816 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
817 if (configured)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
818 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
819 limit_rotation_speed (FALSE);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
820
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
821 if ((x_angle > x_angle_wanted) && (x_speed > 0))
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
822 x_angle = x_angle_wanted;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
823 else if ((x_angle < x_angle_wanted) && (x_speed < 0))
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
824 x_angle = x_angle_wanted;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
825
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
826 x_angle += x_speed;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
827 if (x_angle > 85.0)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
828 x_angle = 85.0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
829 else if (x_angle < 0.0)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
830 x_angle = 0.0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
831
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
832 y_angle += y_speed;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
833 if (y_angle >= 360.0)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
834 y_angle -= 360.0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
835
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
836 z_angle += z_speed;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
837 if (z_angle >= 360.0)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
838 z_angle -= 360.0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
839
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
840 draw_iris ();
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
841 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
842 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
843
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
844 g_log (NULL, G_LOG_LEVEL_DEBUG, __FILE__ ": draw_thread_func: Exiting.");
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
845 pthread_exit (NULL);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
846 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
847
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
848
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
849 static void
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
850 start_display (void)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
851 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
852 scale = 1.0 / log (256.0);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
853
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
854 x_speed = 0.0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
855 y_speed = 0.3;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
856 z_speed = 0.0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
857 x_angle = 45.0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
858 y_angle = 45.0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
859 z_angle = 0.0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
860
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
861 going = TRUE;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
862 limit_fps (TRUE);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
863 limit_rotation_speed (TRUE);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
864 if (pthread_create (&draw_thread, NULL, draw_thread_func, NULL))
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
865 g_log (NULL, G_LOG_LEVEL_CRITICAL, __FILE__ ": pthread_create: Can't create drawing thread.");
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
866
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
867 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
868
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
869
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
870 static void
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
871 stop_display (void)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
872 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
873 if (going)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
874 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
875 going = FALSE;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
876 pthread_join (draw_thread, NULL);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
877 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
878
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
879 kill_gl_window ();
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
880
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
881 if (GLWin.window)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
882 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
883 if (grabbed_pointer)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
884 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
885 XUngrabPointer (GLWin.dpy, CurrentTime);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
886 grabbed_pointer = FALSE;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
887 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
888
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
889 XDestroyWindow (GLWin.dpy, GLWin.window);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
890 GLWin.window = 0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
891 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
892 XCloseDisplay (GLWin.dpy);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
893 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
894
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
895
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
896 static void
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
897 iris_init (void)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
898 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
899 int i;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
900
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
901 initialized = TRUE;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
902 iris_first_init ();
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
903 datas.loudness = 0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
904 /* if the config window is open, we don't want to trash the config the user
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
905 * has done */
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
906 if (!config_window)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
907 iris_config_read ();
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
908 for (i = 0; i < THEME_NUMBER; i++)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
909 if (theme[i].init != NULL)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
910 theme[i].init ();
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
911 srand (666);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
912 start_display ();
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
913 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
914
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
915
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
916 static void
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
917 iris_cleanup (void)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
918 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
919 int i;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
920
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
921 if(initialized)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
922 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
923 stop_display ();
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
924 for (i = 0; i < THEME_NUMBER; i++)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
925 if (theme[i].cleanup != NULL)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
926 theme[i].cleanup ();
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
927 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
928 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
929
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
930
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
931 static void
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
932 iris_playback_start (void)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
933 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
934 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
935
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
936
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
937 static void
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
938 iris_playback_stop (void)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
939 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
940 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
941
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
942
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
943 static void
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
944 iris_render_freq (gint16 data[2][256])
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
945 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
946 GLfloat val;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
947 static int angle = 0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
948 int i;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
949
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
950 for (i = 0; i < num_bands; i++)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
951 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
952 int y, c;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
953 gint xscale[] =
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
954 { 0, 1, 2, 3, 5, 7, 10, 14, 20, 28, 40, 54, 74, 101, 137, 156,
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
955 255
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
956 };
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
957 gint xscale8[] = { 0, 2, 5, 10, 20, 40, 74, 137, 255 };
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
958
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
959 if (num_bands == 16)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
960 for (c = xscale[i], y = 0; c < xscale[i + 1]; c++)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
961 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
962 if (data[0][c] > y)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
963 y = data[0][c];
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
964 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
965 else
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
966 for (c = xscale8[i], y = 0; c < xscale8[i + 1]; c++)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
967 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
968 if (data[0][c] > y)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
969 y = data[0][c];
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
970 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
971
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
972 datas.loudness +=
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
973 (y / (xscale[i + 1] - xscale[i] + 1)) * (abs (i - NUM_BANDS / 2) +
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
974 NUM_BANDS / 2) * (4 + i);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
975
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
976 y >>= 7;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
977 if (y > 0)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
978 val = (log (y) * scale);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
979 else
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
980 val = 0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
981 datas.data360[angle][i] = val;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
982 datas.data1[i] = val;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
983 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
984
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
985 datas.loudness /= (NUM_BANDS * 4);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
986
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
987 beat = detect_beat (datas.loudness);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
988 if (beat)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
989 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
990 beat_before = config.flash_speed;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
991 if (dps <= 90.0)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
992 y_speed += 0.7;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
993
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
994 if (config.bgc_random)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
995 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
996 config.bgc_red = 1.0 * rand () / (RAND_MAX + 1.0);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
997 config.bgc_green = 1.0 * rand () / (RAND_MAX + 1.0);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
998 config.bgc_blue = 1.0 * rand () / (RAND_MAX + 1.0);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
999 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
1000
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
1001 if (config.color12_random)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
1002 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
1003 config.color1_red = 1.0 * rand () / (RAND_MAX + 1.0);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
1004 config.color1_green = 1.0 * rand () / (RAND_MAX + 1.0);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
1005 config.color1_blue = 1.0 * rand () / (RAND_MAX + 1.0);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
1006 config.color2_red = 1.0 * rand () / (RAND_MAX + 1.0);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
1007 config.color2_green = 1.0 * rand () / (RAND_MAX + 1.0);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
1008 config.color2_blue = 1.0 * rand () / (RAND_MAX + 1.0);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
1009 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
1010
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
1011 if (config.color_random)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
1012 {
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
1013 config.color_red = 1.0 * rand () / (RAND_MAX + 1.0);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
1014 config.color_green = 1.0 * rand () / (RAND_MAX + 1.0);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
1015 config.color_blue = 1.0 * rand () / (RAND_MAX + 1.0);
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
1016 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
1017 }
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
1018
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
1019 if (beat_before > 0)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
1020 beat_before--;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
1021
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
1022 angle++;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
1023 if (angle == 360)
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
1024 angle = 0;
a578bf9b2851 [svn] - iris vis plugin port
nenolod
parents:
diff changeset
1025 }