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