2579
|
1 /*
|
|
2 * Audacious - a cross-platform multimedia player
|
|
3 * Copyright (c) 2007 Audacious development team.
|
|
4 *
|
|
5 * Based on:
|
|
6 * BMP - Cross-platform multimedia player
|
|
7 * Copyright (C) 2003-2004 BMP development team.
|
|
8 * XMMS:
|
|
9 * Copyright (C) 1998-2003 XMMS development team.
|
|
10 *
|
|
11 * This program is free software; you can redistribute it and/or modify
|
|
12 * it under the terms of the GNU General Public License as published by
|
|
13 * the Free Software Foundation; under version 3 of the License.
|
|
14 *
|
|
15 * This program is distributed in the hope that it will be useful,
|
|
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
18 * GNU General Public License for more details.
|
|
19 *
|
|
20 * You should have received a copy of the GNU General Public License
|
|
21 * along with this program. If not, see <http://www.gnu.org/licenses>.
|
|
22 *
|
|
23 * The Audacious team does not consider modular code linking to
|
|
24 * Audacious or using our public API to be a derived work.
|
|
25 */
|
|
26
|
|
27 #include "ui_skin.h"
|
|
28 #include "ui_svis.h"
|
|
29 #include "ui_vis.h"
|
|
30 #include "util.h"
|
2584
|
31 #include "skins_cfg.h"
|
2579
|
32 #include <audacious/plugin.h>
|
|
33 #include <string.h>
|
|
34 #include <ctype.h>
|
|
35 #include <gtk/gtkmain.h>
|
|
36 #include <gtk/gtkmarshal.h>
|
|
37 #include <gtk/gtkimage.h>
|
|
38
|
|
39 #define UI_TYPE_SVIS (ui_svis_get_type())
|
|
40
|
|
41 static gint svis_redraw_delays[] = { 1, 2, 4, 8 };
|
|
42
|
|
43 /* FIXME: Are the svis_scope_colors correct? */
|
|
44 static guint8 svis_scope_colors[] = { 20, 19, 18, 19, 20 };
|
|
45 static guint8 svis_vu_normal_colors[] = { 17, 17, 17, 12, 12, 12, 2, 2 };
|
|
46
|
|
47 #define DRAW_DS_PIXEL(ptr,value) \
|
|
48 *(ptr) = (value); \
|
|
49 *((ptr) + 1) = (value); \
|
|
50 *((ptr) + 76) = (value); \
|
|
51 *((ptr) + 77) = (value);
|
|
52
|
|
53 #define SVIS_HEIGHT 5
|
|
54 #define SVIS_WIDTH 38
|
|
55
|
|
56 enum {
|
|
57 DOUBLED,
|
|
58 LAST_SIGNAL
|
|
59 };
|
|
60
|
|
61 static void ui_svis_class_init (UiSVisClass *klass);
|
|
62 static void ui_svis_init (UiSVis *svis);
|
|
63 static void ui_svis_destroy (GtkObject *object);
|
|
64 static void ui_svis_realize (GtkWidget *widget);
|
|
65 static void ui_svis_unrealize (GtkWidget *widget);
|
|
66 static void ui_svis_map (GtkWidget *widget);
|
|
67 static void ui_svis_unmap (GtkWidget *widget);
|
|
68 static void ui_svis_size_request (GtkWidget *widget, GtkRequisition *requisition);
|
|
69 static void ui_svis_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
|
|
70 static gboolean ui_svis_expose (GtkWidget *widget, GdkEventExpose *event);
|
|
71 static void ui_svis_toggle_scaled (UiSVis *svis);
|
|
72
|
|
73 static GtkWidgetClass *parent_class = NULL;
|
|
74 static guint vis_signals[LAST_SIGNAL] = { 0 };
|
|
75
|
|
76 GType ui_svis_get_type() {
|
|
77 static GType vis_type = 0;
|
|
78 if (!vis_type) {
|
|
79 static const GTypeInfo vis_info = {
|
|
80 sizeof (UiSVisClass),
|
|
81 NULL,
|
|
82 NULL,
|
|
83 (GClassInitFunc) ui_svis_class_init,
|
|
84 NULL,
|
|
85 NULL,
|
|
86 sizeof (UiSVis),
|
|
87 0,
|
|
88 (GInstanceInitFunc) ui_svis_init,
|
|
89 };
|
|
90 vis_type = g_type_register_static (GTK_TYPE_WIDGET, "UiSVis", &vis_info, 0);
|
|
91 }
|
|
92
|
|
93 return vis_type;
|
|
94 }
|
|
95
|
|
96 static void ui_svis_class_init(UiSVisClass *klass) {
|
|
97 GtkObjectClass *object_class;
|
|
98 GtkWidgetClass *widget_class;
|
|
99
|
|
100 object_class = (GtkObjectClass*) klass;
|
|
101 widget_class = (GtkWidgetClass*) klass;
|
|
102 parent_class = gtk_type_class (gtk_widget_get_type ());
|
|
103
|
|
104 object_class->destroy = ui_svis_destroy;
|
|
105
|
|
106 widget_class->realize = ui_svis_realize;
|
|
107 widget_class->unrealize = ui_svis_unrealize;
|
|
108 widget_class->map = ui_svis_map;
|
|
109 widget_class->unmap = ui_svis_unmap;
|
|
110 widget_class->expose_event = ui_svis_expose;
|
|
111 widget_class->size_request = ui_svis_size_request;
|
|
112 widget_class->size_allocate = ui_svis_size_allocate;
|
|
113
|
|
114 klass->scaled = ui_svis_toggle_scaled;
|
|
115
|
|
116 vis_signals[DOUBLED] =
|
|
117 g_signal_new ("toggle-scaled", G_OBJECT_CLASS_TYPE (object_class), G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
|
|
118 G_STRUCT_OFFSET (UiSVisClass, scaled), NULL, NULL,
|
|
119 gtk_marshal_VOID__VOID, G_TYPE_NONE, 0);
|
|
120 }
|
|
121
|
|
122 static void ui_svis_init(UiSVis *svis) {
|
|
123
|
|
124 }
|
|
125
|
|
126 GtkWidget* ui_svis_new(GtkWidget *fixed, gint x, gint y) {
|
|
127 UiSVis *svis = g_object_new (ui_svis_get_type (), NULL);
|
|
128
|
|
129 svis->x = x;
|
|
130 svis->y = y;
|
|
131
|
|
132 svis->width = SVIS_WIDTH;
|
|
133 svis->height = SVIS_HEIGHT;
|
|
134
|
|
135 svis->fixed = fixed;
|
|
136 svis->scaled = FALSE;
|
|
137
|
|
138 svis->visible_window = TRUE;
|
|
139 svis->event_window = NULL;
|
|
140
|
|
141 gtk_fixed_put(GTK_FIXED(svis->fixed), GTK_WIDGET(svis), svis->x, svis->y);
|
|
142
|
|
143 return GTK_WIDGET(svis);
|
|
144 }
|
|
145
|
|
146 static void ui_svis_destroy(GtkObject *object) {
|
|
147 UiSVis *svis;
|
|
148
|
|
149 g_return_if_fail (object != NULL);
|
|
150 g_return_if_fail (UI_IS_SVIS (object));
|
|
151
|
|
152 svis = UI_SVIS (object);
|
|
153
|
|
154 if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
|
155 (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
|
|
156 }
|
|
157
|
|
158 static void ui_svis_realize(GtkWidget *widget) {
|
|
159 UiSVis *svis;
|
|
160 GdkWindowAttr attributes;
|
|
161 gint attributes_mask;
|
|
162
|
|
163 g_return_if_fail (widget != NULL);
|
|
164 g_return_if_fail (UI_IS_SVIS(widget));
|
|
165
|
|
166 GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED);
|
|
167 svis = UI_SVIS(widget);
|
|
168
|
|
169 attributes.x = widget->allocation.x;
|
|
170 attributes.y = widget->allocation.y;
|
|
171 attributes.width = widget->allocation.width;
|
|
172 attributes.height = widget->allocation.height;
|
|
173 attributes.window_type = GDK_WINDOW_CHILD;
|
|
174 attributes.event_mask = gtk_widget_get_events(widget);
|
|
175 attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK;
|
|
176
|
|
177 if (svis->visible_window)
|
|
178 {
|
|
179 attributes.visual = gtk_widget_get_visual(widget);
|
|
180 attributes.colormap = gtk_widget_get_colormap(widget);
|
|
181 attributes.wclass = GDK_INPUT_OUTPUT;
|
|
182 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
|
|
183 widget->window = gdk_window_new(widget->parent->window, &attributes, attributes_mask);
|
|
184 GTK_WIDGET_UNSET_FLAGS(widget, GTK_NO_WINDOW);
|
|
185 gdk_window_set_user_data(widget->window, widget);
|
|
186 }
|
|
187 else
|
|
188 {
|
|
189 widget->window = gtk_widget_get_parent_window (widget);
|
|
190 g_object_ref (widget->window);
|
|
191
|
|
192 attributes.wclass = GDK_INPUT_ONLY;
|
|
193 attributes_mask = GDK_WA_X | GDK_WA_Y;
|
|
194 svis->event_window = gdk_window_new (widget->window, &attributes, attributes_mask);
|
|
195 GTK_WIDGET_SET_FLAGS (widget, GTK_NO_WINDOW);
|
|
196 gdk_window_set_user_data(svis->event_window, widget);
|
|
197 }
|
|
198
|
|
199 widget->style = gtk_style_attach(widget->style, widget->window);
|
|
200 }
|
|
201
|
|
202 static void ui_svis_unrealize(GtkWidget *widget) {
|
|
203 UiSVis *svis;
|
|
204 svis = UI_SVIS(widget);
|
|
205
|
|
206 if ( svis->event_window != NULL )
|
|
207 {
|
|
208 gdk_window_set_user_data( svis->event_window , NULL );
|
|
209 gdk_window_destroy( svis->event_window );
|
|
210 svis->event_window = NULL;
|
|
211 }
|
|
212
|
|
213 if (GTK_WIDGET_CLASS (parent_class)->unrealize)
|
|
214 (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
|
|
215 }
|
|
216
|
|
217 static void ui_svis_map(GtkWidget *widget)
|
|
218 {
|
|
219 UiSVis *svis;
|
|
220 svis = UI_SVIS(widget);
|
|
221
|
|
222 if (svis->event_window != NULL)
|
|
223 gdk_window_show (svis->event_window);
|
|
224
|
|
225 if (GTK_WIDGET_CLASS (parent_class)->map)
|
|
226 (* GTK_WIDGET_CLASS (parent_class)->map) (widget);
|
|
227 }
|
|
228
|
|
229 static void ui_svis_unmap (GtkWidget *widget)
|
|
230 {
|
|
231 UiSVis *svis;
|
|
232 svis = UI_SVIS(widget);
|
|
233
|
|
234 if (svis->event_window != NULL)
|
|
235 gdk_window_hide (svis->event_window);
|
|
236
|
|
237 if (GTK_WIDGET_CLASS (parent_class)->unmap)
|
|
238 (* GTK_WIDGET_CLASS (parent_class)->unmap) (widget);
|
|
239 }
|
|
240
|
|
241 static void ui_svis_size_request(GtkWidget *widget, GtkRequisition *requisition) {
|
|
242 UiSVis *svis = UI_SVIS(widget);
|
|
243
|
2584
|
244 requisition->width = svis->width * (svis->scaled ? config.scale_factor : 1);
|
|
245 requisition->height = svis->height*(svis->scaled ? config.scale_factor : 1);
|
2579
|
246 }
|
|
247
|
|
248 static void ui_svis_size_allocate(GtkWidget *widget, GtkAllocation *allocation) {
|
|
249 UiSVis *svis = UI_SVIS (widget);
|
|
250
|
|
251 widget->allocation = *allocation;
|
2584
|
252 widget->allocation.x *= (svis->scaled ? config.scale_factor : 1 );
|
|
253 widget->allocation.y *= (svis->scaled ? config.scale_factor : 1);
|
2579
|
254 if (GTK_WIDGET_REALIZED (widget))
|
|
255 {
|
|
256 if (svis->event_window != NULL)
|
|
257 gdk_window_move_resize(svis->event_window, widget->allocation.x, widget->allocation.y, allocation->width, allocation->height);
|
|
258 else
|
|
259 gdk_window_move_resize(widget->window, widget->allocation.x, widget->allocation.y, allocation->width, allocation->height);
|
|
260 }
|
|
261
|
2584
|
262 svis->x = widget->allocation.x/(svis->scaled ? config.scale_factor : 1);
|
|
263 svis->y = widget->allocation.y/(svis->scaled ? config.scale_factor : 1);
|
2579
|
264 }
|
|
265
|
|
266 static gboolean ui_svis_expose(GtkWidget *widget, GdkEventExpose *event) {
|
|
267 g_return_val_if_fail (widget != NULL, FALSE);
|
|
268 g_return_val_if_fail (UI_IS_SVIS (widget), FALSE);
|
|
269 g_return_val_if_fail (event != NULL, FALSE);
|
|
270
|
|
271 UiSVis *svis = UI_SVIS (widget);
|
|
272
|
|
273 gint x, y, h;
|
|
274 guchar svis_color[24][3];
|
|
275 guchar rgb_data[SVIS_WIDTH * 2 * SVIS_HEIGHT * 2], *ptr, c;
|
|
276 guint32 colors[24];
|
|
277 GdkRgbCmap *cmap;
|
|
278
|
|
279 if (!GTK_WIDGET_VISIBLE(widget))
|
|
280 return FALSE;
|
|
281
|
|
282 if (!svis->visible_window)
|
|
283 return FALSE;
|
|
284
|
|
285 skin_get_viscolor(aud_active_skin, svis_color);
|
|
286 for (y = 0; y < 24; y++) {
|
|
287 colors[y] =
|
|
288 svis_color[y][0] << 16 | svis_color[y][1] << 8 | svis_color[y][2];
|
|
289 }
|
|
290 cmap = gdk_rgb_cmap_new(colors, 24);
|
|
291
|
2584
|
292 if (!config.scaled) {
|
2579
|
293 memset(rgb_data, 0, SVIS_WIDTH * SVIS_HEIGHT);
|
2584
|
294 if (config.vis_type == VIS_ANALYZER && !audacious_drct_get_paused() && audacious_drct_get_playing()){
|
2579
|
295 for(y=0; y < SVIS_HEIGHT; y++){
|
2584
|
296 if (config.analyzer_type == ANALYZER_BARS){
|
2579
|
297 for(x=0;x< SVIS_WIDTH; x++){
|
|
298 if(svis->data[x] > y << 1)
|
|
299 {
|
|
300 rgb_data[x*3+ (SVIS_HEIGHT - y) * SVIS_WIDTH] = 23;
|
|
301 rgb_data[x*3+1 + (SVIS_HEIGHT - y) * SVIS_WIDTH] = 23;
|
|
302
|
|
303 }
|
|
304 }
|
|
305 }
|
|
306 else{
|
|
307 for(x=0;x< SVIS_WIDTH; x++){
|
|
308 if(svis->data[x] > y << 1)
|
|
309 {
|
|
310 rgb_data[x + (SVIS_HEIGHT - y) * SVIS_WIDTH] = 23;
|
|
311 }
|
|
312 }
|
|
313 }
|
|
314 }
|
|
315 }
|
2584
|
316 else if (config.vis_type == VIS_VOICEPRINT){
|
|
317 switch (config.vu_mode) {
|
2579
|
318 case VU_NORMAL:
|
|
319 for (y = 0; y < 2; y++) {
|
|
320 ptr = rgb_data + ((y * 3) * 38);
|
|
321 h = (svis->data[y] * 7) / 37;
|
|
322 for (x = 0; x < h; x++, ptr += 5) {
|
|
323 c = svis_vu_normal_colors[x];
|
|
324 *(ptr) = c;
|
|
325 *(ptr + 1) = c;
|
|
326 *(ptr + 2) = c;
|
|
327 *(ptr + 38) = c;
|
|
328 *(ptr + 39) = c;
|
|
329 *(ptr + 40) = c;
|
|
330 }
|
|
331 }
|
|
332 break;
|
|
333 case VU_SMOOTH:
|
|
334 for (y = 0; y < 2; y++) {
|
|
335 ptr = rgb_data + ((y * 3) * SVIS_WIDTH);
|
|
336 for (x = 0; x < svis->data[y]; x++, ptr++) {
|
|
337 c = 17 - ((x * 15) / 37);
|
|
338 *(ptr) = c;
|
|
339 *(ptr + 38) = c;
|
|
340 }
|
|
341 }
|
|
342 break;
|
|
343 }
|
|
344 }
|
2584
|
345 else if (config.vis_type == VIS_SCOPE) {
|
2579
|
346 for (x = 0; x < 38; x++) {
|
|
347 h = svis->data[x << 1] / 3;
|
|
348 ptr = rgb_data + ((4 - h) * 38) + x;
|
|
349 *ptr = svis_scope_colors[h];
|
|
350 }
|
|
351 }
|
|
352
|
|
353 }
|
|
354 else { /*svis scaling, this needs some work, since a lot of stuff is hardcoded --majeru*/
|
|
355
|
2642
|
356 memset(rgb_data, 0, SVIS_WIDTH * config.scale_factor * SVIS_HEIGHT * config.scale_factor);
|
2584
|
357 if (config.vis_type == VIS_ANALYZER && !audacious_drct_get_paused() && audacious_drct_get_playing()){
|
2579
|
358 for(y=0; y < SVIS_HEIGHT; y++){
|
2584
|
359 if (config.analyzer_type == ANALYZER_BARS){
|
2579
|
360 for(x=0;x< SVIS_WIDTH; x++){
|
|
361 if(svis->data[x] > y << 1)
|
|
362 {
|
|
363 ptr = rgb_data + x * 6 + (SVIS_HEIGHT * 2 - y * 2) * SVIS_WIDTH *2;
|
|
364 DRAW_DS_PIXEL(ptr, 23);
|
|
365 DRAW_DS_PIXEL(ptr + 2, 23);
|
|
366 }
|
|
367 }
|
|
368 }
|
|
369 else{
|
|
370 for(x=0;x< SVIS_WIDTH; x++){
|
|
371 if(svis->data[x] > y << 1)
|
|
372 {
|
|
373 ptr = rgb_data + x * 2 + (SVIS_HEIGHT * 2 - y * 2) * SVIS_WIDTH * 2;
|
|
374 DRAW_DS_PIXEL(ptr, 23);
|
|
375 }
|
|
376 }
|
|
377 }
|
|
378 }
|
|
379 }
|
2584
|
380 else if (config.vis_type == VIS_VOICEPRINT){
|
|
381 switch (config.vu_mode) {
|
2579
|
382 case VU_NORMAL:
|
|
383 for (y = 0; y < 2; y++) {
|
|
384 ptr = rgb_data + ((y * 3) * 152);
|
|
385 h = (svis->data[y] * 8) / 37;
|
|
386 for (x = 0; x < h; x++, ptr += 10) {
|
|
387 c = svis_vu_normal_colors[x];
|
|
388 DRAW_DS_PIXEL(ptr, c);
|
|
389 DRAW_DS_PIXEL(ptr + 2, c);
|
|
390 DRAW_DS_PIXEL(ptr + 4, c);
|
|
391 DRAW_DS_PIXEL(ptr + 152, c);
|
|
392 DRAW_DS_PIXEL(ptr + 154, c);
|
|
393 DRAW_DS_PIXEL(ptr + 156, c);
|
|
394 }
|
|
395 }
|
|
396 break;
|
|
397 case VU_SMOOTH:
|
|
398 for (y = 0; y < 2; y++) {
|
|
399 ptr = rgb_data + ((y * 3) * 152);
|
|
400 for (x = 0; x < svis->data[y]; x++, ptr += 2) {
|
|
401 c = 17 - ((x * 15) / 37);
|
|
402 DRAW_DS_PIXEL(ptr, c);
|
|
403 DRAW_DS_PIXEL(ptr + 152, c);
|
|
404 }
|
|
405 }
|
|
406 break;
|
|
407 }
|
|
408 }
|
2584
|
409 else if (config.vis_type == VIS_SCOPE) {
|
2579
|
410 for (x = 0; x < 38; x++) {
|
|
411 h = svis->data[x << 1] / 3;
|
|
412 ptr = rgb_data + ((4 - h) * 152) + (x << 1);
|
|
413 *ptr = svis_scope_colors[h];
|
|
414 *(ptr + 1) = svis_scope_colors[h];
|
|
415 *(ptr + 76) = svis_scope_colors[h];
|
|
416 *(ptr + 77) = svis_scope_colors[h];
|
|
417 }
|
|
418 }
|
|
419
|
|
420
|
|
421 }
|
|
422
|
|
423 GdkPixmap *obj = NULL;
|
|
424 GdkGC *gc;
|
2584
|
425 obj = gdk_pixmap_new(NULL, svis->width* ( svis->scaled ? config.scale_factor : 1),
|
|
426 svis->height*(svis->scaled ? config.scale_factor : 1), gdk_rgb_get_visual()->depth);
|
2579
|
427 gc = gdk_gc_new(obj);
|
|
428
|
|
429 if (!svis->scaled) {
|
|
430 gdk_draw_indexed_image(obj, gc, 0, 0, svis->width, svis->height,
|
|
431 GDK_RGB_DITHER_NORMAL, (guchar *) rgb_data,
|
|
432 38, cmap);
|
|
433 } else {
|
|
434 gdk_draw_indexed_image(obj, gc,
|
|
435 0 << 1, 0 << 1,
|
|
436 svis->width << 1, svis->height << 1,
|
|
437 GDK_RGB_DITHER_NONE, (guchar *) rgb_data,
|
|
438 76, cmap);
|
|
439 }
|
|
440
|
|
441 gdk_rgb_cmap_free(cmap);
|
|
442 gdk_draw_drawable (widget->window, gc, obj, 0, 0, 0, 0,
|
2584
|
443 svis->width*(svis->scaled ? config.scale_factor : 1),
|
|
444 svis->height*(svis->scaled ? config.scale_factor : 1));
|
2579
|
445 g_object_unref(obj);
|
|
446 g_object_unref(gc);
|
|
447
|
|
448 return FALSE;
|
|
449 }
|
|
450
|
|
451 static void ui_svis_toggle_scaled(UiSVis *svis) {
|
|
452 GtkWidget *widget = GTK_WIDGET (svis);
|
|
453 svis->scaled = !svis->scaled;
|
|
454
|
2642
|
455 gtk_widget_set_size_request(widget, svis->width* config.scale_factor, svis->height * config.scale_factor);
|
2579
|
456
|
|
457 gtk_widget_queue_draw(widget);
|
|
458 }
|
|
459
|
|
460 void ui_svis_set_visible(GtkWidget *widget, gboolean window_is_visible)
|
|
461 {
|
|
462 UiSVis *svis;
|
|
463 gboolean widget_is_visible;
|
|
464
|
|
465 g_return_if_fail(UI_IS_SVIS(widget));
|
|
466
|
|
467 svis = UI_SVIS (widget);
|
|
468 widget_is_visible = GTK_WIDGET_VISIBLE(widget);
|
|
469
|
|
470 svis->visible_window = window_is_visible;
|
|
471
|
|
472 if (GTK_WIDGET_REALIZED (widget))
|
|
473 {
|
|
474 if ( widget_is_visible )
|
|
475 gtk_widget_hide(widget);
|
|
476
|
|
477 gtk_widget_unrealize(widget);
|
|
478 gtk_widget_realize(widget);
|
|
479
|
|
480 if ( widget_is_visible )
|
|
481 gtk_widget_show(widget);
|
|
482 }
|
|
483
|
|
484 if (widget_is_visible)
|
|
485 gtk_widget_queue_resize(widget);
|
|
486 }
|
|
487
|
|
488 void ui_svis_clear_data(GtkWidget *widget) {
|
2669
|
489 g_return_if_fail(UI_IS_SVIS(widget));
|
|
490
|
2579
|
491 gint i;
|
|
492 UiSVis *svis = UI_SVIS (widget);
|
|
493
|
|
494 for (i = 0; i < 75; i++) {
|
2584
|
495 svis->data[i] = (config.vis_type == VIS_SCOPE) ? 6 : 0;
|
2579
|
496 }
|
|
497 }
|
|
498
|
|
499 void ui_svis_timeout_func(GtkWidget *widget, guchar * data) {
|
2669
|
500 g_return_if_fail(UI_IS_SVIS(widget));
|
|
501
|
2579
|
502 UiSVis *svis = UI_SVIS (widget);
|
|
503 static GTimer *timer = NULL;
|
|
504 gulong micros = 9999999;
|
|
505 gboolean falloff = FALSE;
|
|
506 gint i;
|
|
507
|
|
508 if (!timer) {
|
|
509 timer = g_timer_new();
|
|
510 g_timer_start(timer);
|
|
511 }
|
|
512 else {
|
|
513 g_timer_elapsed(timer, µs);
|
|
514 if (micros > 14000)
|
|
515 g_timer_reset(timer);
|
|
516
|
|
517 }
|
|
518
|
2584
|
519 if (config.vis_type == VIS_VOICEPRINT) {
|
2579
|
520 if (micros > 14000)
|
|
521 falloff = TRUE;
|
|
522
|
|
523 for (i = 0; i < 2; i++) {
|
|
524 if (falloff || data) {
|
|
525 if (data && data[i] > svis->data[i])
|
|
526 svis->data[i] = data[i];
|
|
527 else if (falloff) {
|
|
528 if (svis->data[i] >= 2)
|
|
529 svis->data[i] -= 2;
|
|
530 else
|
|
531 svis->data[i] = 0;
|
|
532 }
|
|
533 }
|
|
534
|
|
535 }
|
|
536 }
|
|
537 else if (data) {
|
|
538 for (i = 0; i < 75; i++)
|
|
539 svis->data[i] = data[i];
|
|
540 }
|
|
541
|
|
542 if (micros > 14000) {
|
|
543 if (!svis->refresh_delay) {
|
|
544 gtk_widget_queue_draw(widget);
|
2584
|
545 svis->refresh_delay = svis_redraw_delays[config.vis_refresh];
|
2579
|
546 }
|
|
547 svis->refresh_delay--;
|
|
548 }
|
|
549 }
|