Mercurial > audlegacy-plugins
comparison src/skins/ui_vis.c @ 2584:c9e40418a74c
use plugin's own config
author | Tomasz Mon <desowin@gmail.com> |
---|---|
date | Tue, 20 May 2008 19:41:12 +0200 |
parents | 8fba3fbf1a0f |
children | c2603047a1a3 |
comparison
equal
deleted
inserted
replaced
2583:294232665cb0 | 2584:c9e40418a74c |
---|---|
25 */ | 25 */ |
26 | 26 |
27 #include "ui_skin.h" | 27 #include "ui_skin.h" |
28 #include "ui_vis.h" | 28 #include "ui_vis.h" |
29 #include "util.h" | 29 #include "util.h" |
30 #include "skins_cfg.h" | |
30 #include <audacious/plugin.h> | 31 #include <audacious/plugin.h> |
31 | 32 |
32 static const gfloat vis_afalloff_speeds[] = { 0.34, 0.5, 1.0, 1.3, 1.6 }; | 33 static const gfloat vis_afalloff_speeds[] = { 0.34, 0.5, 1.0, 1.3, 1.6 }; |
33 static const gfloat vis_pfalloff_speeds[] = { 1.2, 1.3, 1.4, 1.5, 1.6 }; | 34 static const gfloat vis_pfalloff_speeds[] = { 1.2, 1.3, 1.4, 1.5, 1.6 }; |
34 static const gint vis_redraw_delays[] = { 1, 2, 4, 8 }; | 35 static const gint vis_redraw_delays[] = { 1, 2, 4, 8 }; |
222 } | 223 } |
223 | 224 |
224 static void ui_vis_size_request(GtkWidget *widget, GtkRequisition *requisition) { | 225 static void ui_vis_size_request(GtkWidget *widget, GtkRequisition *requisition) { |
225 UiVis *vis = UI_VIS(widget); | 226 UiVis *vis = UI_VIS(widget); |
226 | 227 |
227 requisition->width = vis->width*(vis->scaled ? aud_cfg->scale_factor : 1); | 228 requisition->width = vis->width*(vis->scaled ? config.scale_factor : 1); |
228 requisition->height = vis->height*(vis->scaled ? aud_cfg->scale_factor : 1); | 229 requisition->height = vis->height*(vis->scaled ? config.scale_factor : 1); |
229 } | 230 } |
230 | 231 |
231 static void ui_vis_size_allocate(GtkWidget *widget, GtkAllocation *allocation) { | 232 static void ui_vis_size_allocate(GtkWidget *widget, GtkAllocation *allocation) { |
232 UiVis *vis = UI_VIS (widget); | 233 UiVis *vis = UI_VIS (widget); |
233 | 234 |
234 widget->allocation = *allocation; | 235 widget->allocation = *allocation; |
235 widget->allocation.x *= (vis->scaled ? aud_cfg->scale_factor : 1); | 236 widget->allocation.x *= (vis->scaled ? config.scale_factor : 1); |
236 widget->allocation.y *= (vis->scaled ? aud_cfg->scale_factor : 1); | 237 widget->allocation.y *= (vis->scaled ? config.scale_factor : 1); |
237 if (GTK_WIDGET_REALIZED (widget)) | 238 if (GTK_WIDGET_REALIZED (widget)) |
238 { | 239 { |
239 if (vis->event_window != NULL) | 240 if (vis->event_window != NULL) |
240 gdk_window_move_resize(vis->event_window, widget->allocation.x, widget->allocation.y, allocation->width, allocation->height); | 241 gdk_window_move_resize(vis->event_window, widget->allocation.x, widget->allocation.y, allocation->width, allocation->height); |
241 else | 242 else |
242 gdk_window_move_resize(widget->window, widget->allocation.x, widget->allocation.y, allocation->width, allocation->height); | 243 gdk_window_move_resize(widget->window, widget->allocation.x, widget->allocation.y, allocation->width, allocation->height); |
243 } | 244 } |
244 | 245 |
245 vis->x = widget->allocation.x/(vis->scaled ? aud_cfg->scale_factor : 1); | 246 vis->x = widget->allocation.x/(vis->scaled ? config.scale_factor : 1); |
246 vis->y = widget->allocation.y/(vis->scaled ? aud_cfg->scale_factor : 1); | 247 vis->y = widget->allocation.y/(vis->scaled ? config.scale_factor : 1); |
247 } | 248 } |
248 | 249 |
249 static gboolean ui_vis_expose(GtkWidget *widget, GdkEventExpose *event) { | 250 static gboolean ui_vis_expose(GtkWidget *widget, GdkEventExpose *event) { |
250 g_return_val_if_fail (widget != NULL, FALSE); | 251 g_return_val_if_fail (widget != NULL, FALSE); |
251 g_return_val_if_fail (UI_IS_VIS (widget), FALSE); | 252 g_return_val_if_fail (UI_IS_VIS (widget), FALSE); |
275 vis_color[y][0] << 16 | vis_color[y][1] << 8 | vis_color[y][2]; | 276 vis_color[y][0] << 16 | vis_color[y][1] << 8 | vis_color[y][2]; |
276 } | 277 } |
277 cmap = gdk_rgb_cmap_new(colors, 24); | 278 cmap = gdk_rgb_cmap_new(colors, 24); |
278 | 279 |
279 if (!vis->scaled) { | 280 if (!vis->scaled) { |
280 if(aud_cfg->vis_type == VIS_VOICEPRINT /*&& aud_cfg->voiceprint_mode != VOICEPRINT_NORMAL*/){ | 281 if(config.vis_type == VIS_VOICEPRINT /*&& aud_cfg->voiceprint_mode != VOICEPRINT_NORMAL*/){ |
281 memset(rgb_data, 0, 76 * 16 * 3); | 282 memset(rgb_data, 0, 76 * 16 * 3); |
282 } | 283 } |
283 else{ | 284 else{ |
284 memset(rgb_data, 0, 76 * 16); | 285 memset(rgb_data, 0, 76 * 16); |
285 for (y = 1; y < 16; y += 2) { | 286 for (y = 1; y < 16; y += 2) { |
288 *ptr = 1; | 289 *ptr = 1; |
289 } | 290 } |
290 } | 291 } |
291 } | 292 } |
292 else{ | 293 else{ |
293 if(aud_cfg->vis_type == VIS_VOICEPRINT /*&& aud_cfg->voiceprint_mode != VOICEPRINT_NORMAL*/){ | 294 if(config.vis_type == VIS_VOICEPRINT /*&& aud_cfg->voiceprint_mode != VOICEPRINT_NORMAL*/){ |
294 memset(rgb_data, 0, 3 * 4 * 16 * 76); | 295 memset(rgb_data, 0, 3 * 4 * 16 * 76); |
295 } | 296 } |
296 else{ | 297 else{ |
297 memset(rgb_data, 0, (guint)(76 * aud_cfg->scale_factor) * 32); | 298 memset(rgb_data, 0, (guint)(76 * config.scale_factor) * 32); |
298 for (y = 1; y < 16; y += 2) { | 299 for (y = 1; y < 16; y += 2) { |
299 ptr = rgb_data + (y * (guint)(76 * 4 * aud_cfg->scale_factor)); | 300 ptr = rgb_data + (y * (guint)(76 * 4 * config.scale_factor)); |
300 for (x = 0; x < 76; x += 2, ptr += 4) { | 301 for (x = 0; x < 76; x += 2, ptr += 4) { |
301 *ptr = 1; | 302 *ptr = 1; |
302 *(ptr + 1) = 1; | 303 *(ptr + 1) = 1; |
303 *(ptr + (guint)(76 * aud_cfg->scale_factor)) = 1; | 304 *(ptr + (guint)(76 * config.scale_factor)) = 1; |
304 *(ptr + (guint)(76 * aud_cfg->scale_factor)+1) = 1; | 305 *(ptr + (guint)(76 * config.scale_factor)+1) = 1; |
305 } | 306 } |
306 } | 307 } |
307 } | 308 } |
308 } | 309 } |
309 if (aud_cfg->vis_type == VIS_ANALYZER) { | 310 if (config.vis_type == VIS_ANALYZER) { |
310 for (x = 0; x < 75; x++) { | 311 for (x = 0; x < 75; x++) { |
311 if (aud_cfg->analyzer_type == ANALYZER_BARS && (x % 4) == 0) | 312 if (config.analyzer_type == ANALYZER_BARS && (x % 4) == 0) |
312 h = vis->data[x >> 2]; | 313 h = vis->data[x >> 2]; |
313 else if (aud_cfg->analyzer_type == ANALYZER_LINES) | 314 else if (config.analyzer_type == ANALYZER_LINES) |
314 h = vis->data[x]; | 315 h = vis->data[x]; |
315 if (h && (aud_cfg->analyzer_type == ANALYZER_LINES || | 316 if (h && (config.analyzer_type == ANALYZER_LINES || |
316 (x % 4) != 3)) { | 317 (x % 4) != 3)) { |
317 if (!vis->scaled) { | 318 if (!vis->scaled) { |
318 ptr = rgb_data + ((16 - h) * 76) + x; | 319 ptr = rgb_data + ((16 - h) * 76) + x; |
319 switch (aud_cfg->analyzer_mode) { | 320 switch (config.analyzer_mode) { |
320 case ANALYZER_NORMAL: | 321 case ANALYZER_NORMAL: |
321 for (y = 0; y < h; y++, ptr += 76) | 322 for (y = 0; y < h; y++, ptr += 76) |
322 *ptr = 18 - h + y; | 323 *ptr = 18 - h + y; |
323 break; | 324 break; |
324 case ANALYZER_FIRE: | 325 case ANALYZER_FIRE: |
330 *ptr = 18 - h; | 331 *ptr = 18 - h; |
331 break; | 332 break; |
332 } | 333 } |
333 } | 334 } |
334 else{ | 335 else{ |
335 ptr = rgb_data + ((16 - h) * (guint)(76 * 4 * aud_cfg->scale_factor)) + (guint)(x * aud_cfg->scale_factor); | 336 ptr = rgb_data + ((16 - h) * (guint)(76 * 4 * config.scale_factor)) + (guint)(x * aud_cfg->scale_factor); |
336 switch (aud_cfg->analyzer_mode) { | 337 switch (config.analyzer_mode) { |
337 case ANALYZER_NORMAL: | 338 case ANALYZER_NORMAL: |
338 for (y = 0; y < h; y++, ptr += (guint)(76 * 4 * aud_cfg->scale_factor)) { | 339 for (y = 0; y < h; y++, ptr += (guint)(76 * 4 * config.scale_factor)) { |
339 *ptr = 18 - h + y; | 340 *ptr = 18 - h + y; |
340 *(ptr + 1) = 18 - h + y; | 341 *(ptr + 1) = 18 - h + y; |
341 *(ptr + (guint)(76 * aud_cfg->scale_factor)) = 18 - h + y; | 342 *(ptr + (guint)(76 * config.scale_factor)) = 18 - h + y; |
342 *(ptr + (guint)(76 * aud_cfg->scale_factor)+1) = 18 - h + y; | 343 *(ptr + (guint)(76 * config.scale_factor)+1) = 18 - h + y; |
343 } | 344 } |
344 break; | 345 break; |
345 case ANALYZER_FIRE: | 346 case ANALYZER_FIRE: |
346 for (y = 0; y < h; y++, ptr += (guint)(76 * 4 * aud_cfg->scale_factor)) { | 347 for (y = 0; y < h; y++, ptr += (guint)(76 * 4 * config.scale_factor)) { |
347 *ptr = y + 2; | 348 *ptr = y + 2; |
348 *(ptr + 1) = y + 2; | 349 *(ptr + 1) = y + 2; |
349 *(ptr + (guint)(76 * aud_cfg->scale_factor)) = y + 2; | 350 *(ptr + (guint)(76 * config.scale_factor)) = y + 2; |
350 *(ptr + (guint)(76 * aud_cfg->scale_factor)+1) = y + 2; | 351 *(ptr + (guint)(76 * config.scale_factor)+1) = y + 2; |
351 } | 352 } |
352 break; | 353 break; |
353 case ANALYZER_VLINES: | 354 case ANALYZER_VLINES: |
354 for (y = 0; y < h; y++, ptr += (guint)(76 * 4 * aud_cfg->scale_factor)) { | 355 for (y = 0; y < h; y++, ptr += (guint)(76 * 4 * config.scale_factor)) { |
355 *ptr = 18 - h; | 356 *ptr = 18 - h; |
356 *(ptr + 1) = 18 - h; | 357 *(ptr + 1) = 18 - h; |
357 *(ptr + (guint)(76 * aud_cfg->scale_factor)) = 18 - h; | 358 *(ptr + (guint)(76 * config.scale_factor)) = 18 - h; |
358 *(ptr + (guint)(76 * aud_cfg->scale_factor)+1) = 18 - h; | 359 *(ptr + (guint)(76 * config.scale_factor)+1) = 18 - h; |
359 } | 360 } |
360 | 361 |
361 break; | 362 break; |
362 } | 363 } |
363 } | 364 } |
364 } | 365 } |
365 } | 366 } |
366 if (aud_cfg->analyzer_peaks) { | 367 if (config.analyzer_peaks) { |
367 for (x = 0; x < 75; x++) { | 368 for (x = 0; x < 75; x++) { |
368 if (aud_cfg->analyzer_type == ANALYZER_BARS && (x % 4) == 0) | 369 if (config.analyzer_type == ANALYZER_BARS && (x % 4) == 0) |
369 h = vis->peak[x >> 2]; | 370 h = vis->peak[x >> 2]; |
370 else if (aud_cfg->analyzer_type == ANALYZER_LINES) | 371 else if (config.analyzer_type == ANALYZER_LINES) |
371 h = vis->peak[x]; | 372 h = vis->peak[x]; |
372 if (h && (aud_cfg->analyzer_type == ANALYZER_LINES || (x % 4) != 3)){ | 373 if (h && (config.analyzer_type == ANALYZER_LINES || (x % 4) != 3)){ |
373 | 374 |
374 if (!vis->scaled) { | 375 if (!vis->scaled) { |
375 rgb_data[(16 - h) * 76 + x] = 23; | 376 rgb_data[(16 - h) * 76 + x] = 23; |
376 } | 377 } |
377 else{ | 378 else{ |
378 ptr = rgb_data + (16 - h) * (guint)(76 * 4 * aud_cfg->scale_factor) + (guint)(x * aud_cfg->scale_factor); | 379 ptr = rgb_data + (16 - h) * (guint)(76 * 4 * config.scale_factor) + (guint)(x * aud_cfg->scale_factor); |
379 *ptr = 23; | 380 *ptr = 23; |
380 *(ptr + 1) = 23; | 381 *(ptr + 1) = 23; |
381 *(ptr + (guint)(76 * aud_cfg->scale_factor)) = 23; | 382 *(ptr + (guint)(76 * config.scale_factor)) = 23; |
382 *(ptr + (guint)(76 * aud_cfg->scale_factor)+1) = 23; | 383 *(ptr + (guint)(76 * config.scale_factor)+1) = 23; |
383 } | 384 } |
384 } | 385 } |
385 } | 386 } |
386 } | 387 } |
387 } | 388 } |
388 else if (aud_cfg->vis_type == VIS_VOICEPRINT) { | 389 else if (config.vis_type == VIS_VOICEPRINT) { |
389 if(!audacious_drct_get_paused() && audacious_drct_get_playing()){/*Don't scroll when it's paused or stopped*/ | 390 if(!audacious_drct_get_paused() && audacious_drct_get_playing()){/*Don't scroll when it's paused or stopped*/ |
390 for (y = 0; y < 16; y ++) | 391 for (y = 0; y < 16; y ++) |
391 for (x = 75; x > 0; x--) | 392 for (x = 75; x > 0; x--) |
392 voiceprint_data[x + y * 76] = voiceprint_data[x-1+y*76]; | 393 voiceprint_data[x + y * 76] = voiceprint_data[x-1+y*76]; |
393 for(y=0;y<16;y++) | 394 for(y=0;y<16;y++) |
394 voiceprint_data[y * 76] = vis->data[y]; | 395 voiceprint_data[y * 76] = vis->data[y]; |
395 } | 396 } |
396 if(audacious_drct_get_playing()){ /*Only draw the data if we're playing*/ | 397 if(audacious_drct_get_playing()){ /*Only draw the data if we're playing*/ |
397 if(aud_cfg->voiceprint_mode == VOICEPRINT_NORMAL){ | 398 if(config.voiceprint_mode == VOICEPRINT_NORMAL){ |
398 /* Create color gradient from the skin's background- and foreground color*/ | 399 /* Create color gradient from the skin's background- and foreground color*/ |
399 fgc = skin_get_color(aud_active_skin, SKIN_TEXTFG); | 400 fgc = skin_get_color(aud_active_skin, SKIN_TEXTFG); |
400 bgc = skin_get_color(aud_active_skin, SKIN_TEXTBG); | 401 bgc = skin_get_color(aud_active_skin, SKIN_TEXTBG); |
401 skin_col[0][0] = fgc->red >> 8; | 402 skin_col[0][0] = fgc->red >> 8; |
402 skin_col[0][1] = fgc->green >> 8; | 403 skin_col[0][1] = fgc->green >> 8; |
422 } | 423 } |
423 for (y = 0; y < 16; y ++){ | 424 for (y = 0; y < 16; y ++){ |
424 for (x = 0; x < 76; x++){ | 425 for (x = 0; x < 76; x++){ |
425 guint8 d = voiceprint_data[x + y*76]; | 426 guint8 d = voiceprint_data[x + y*76]; |
426 | 427 |
427 if(aud_cfg->voiceprint_mode == VOICEPRINT_NORMAL){ | 428 if(config.voiceprint_mode == VOICEPRINT_NORMAL){ |
428 voice_c[0] = vis_voice_color[d][0]; | 429 voice_c[0] = vis_voice_color[d][0]; |
429 voice_c[1] = vis_voice_color[d][1]; | 430 voice_c[1] = vis_voice_color[d][1]; |
430 voice_c[2] = vis_voice_color[d][2]; | 431 voice_c[2] = vis_voice_color[d][2]; |
431 } | 432 } |
432 else if(aud_cfg->voiceprint_mode == VOICEPRINT_FIRE){ | 433 else if(config.voiceprint_mode == VOICEPRINT_FIRE){ |
433 voice_c[0] = d < 64 ? (d * 2) : 255; | 434 voice_c[0] = d < 64 ? (d * 2) : 255; |
434 voice_c[1] = d < 64 ? 0 : (d < 128 ? (d-64) * 2 : 255); | 435 voice_c[1] = d < 64 ? 0 : (d < 128 ? (d-64) * 2 : 255); |
435 voice_c[2] = d < 128 ? 0 : (d-128) * 2; | 436 voice_c[2] = d < 128 ? 0 : (d-128) * 2; |
436 /* Test for black->blue->green->red. Isn't pretty, though... | 437 /* Test for black->blue->green->red. Isn't pretty, though... |
437 voice_c[0] = d > 192 ? (d - 192) << 2 : 0; | 438 voice_c[0] = d > 192 ? (d - 192) << 2 : 0; |
438 voice_c[1] = d > 64 ? (d < 128 ? (d - 64) << 2 : (d < 192 ? (192 - d) << 2 : 0)) : 0; | 439 voice_c[1] = d > 64 ? (d < 128 ? (d - 64) << 2 : (d < 192 ? (192 - d) << 2 : 0)) : 0; |
439 voice_c[2] = d < 64 ? d << 2 : (d < 128 ? (128 - d) << 2 : 0); | 440 voice_c[2] = d < 64 ? d << 2 : (d < 128 ? (128 - d) << 2 : 0); |
440 */ | 441 */ |
441 } | 442 } |
442 else if(aud_cfg->voiceprint_mode == VOICEPRINT_ICE){ | 443 else if(config.voiceprint_mode == VOICEPRINT_ICE){ |
443 voice_c[0] = d; | 444 voice_c[0] = d; |
444 voice_c[1] = d < 128 ? d * 2 : 255; | 445 voice_c[1] = d < 128 ? d * 2 : 255; |
445 voice_c[2] = d < 64 ? d * 4 : 255; | 446 voice_c[2] = d < 64 ? d * 4 : 255; |
446 } | 447 } |
447 if(!vis->scaled){ | 448 if(!vis->scaled){ |
448 for(n=0;n<3;n++) | 449 for(n=0;n<3;n++) |
449 rgb_data[x * 3 + y * 76*3+n] = voice_c[n]; | 450 rgb_data[x * 3 + y * 76*3+n] = voice_c[n]; |
450 } | 451 } |
451 else{ | 452 else{ |
452 ptr = rgb_data + (guint)(x * 3 * aud_cfg->scale_factor) + (guint) (y * 76 * 3 * aud_cfg->scale_factor); | 453 ptr = rgb_data + (guint)(x * 3 * config.scale_factor) + (guint) (y * 76 * 3 * aud_cfg->scale_factor); |
453 for(n=0;n<3;n++) | 454 for(n=0;n<3;n++) |
454 { | 455 { |
455 *(ptr + n) = voice_c[n]; | 456 *(ptr + n) = voice_c[n]; |
456 *(ptr + n + 3) = voice_c[n]; | 457 *(ptr + n + 3) = voice_c[n]; |
457 *(ptr + (guint)(n + 76 * aud_cfg->scale_factor * 3)) = voice_c[n]; | 458 *(ptr + (guint)(n + 76 * config.scale_factor * 3)) = voice_c[n]; |
458 *(ptr + (guint)(n + 3 + 76 * aud_cfg->scale_factor * 3)) = voice_c[n]; | 459 *(ptr + (guint)(n + 3 + 76 * config.scale_factor * 3)) = voice_c[n]; |
459 } | 460 } |
460 } | 461 } |
461 } | 462 } |
462 } | 463 } |
463 } | 464 } |
464 } | 465 } |
465 if (aud_cfg->vis_type == VIS_SCOPE) { | 466 if (config.vis_type == VIS_SCOPE) { |
466 for (x = 0; x < 75; x++) { | 467 for (x = 0; x < 75; x++) { |
467 switch (aud_cfg->scope_mode) { | 468 switch (config.scope_mode) { |
468 case SCOPE_DOT: | 469 case SCOPE_DOT: |
469 h = vis->data[x]; | 470 h = vis->data[x]; |
470 if (!vis->scaled) { | 471 if (!vis->scaled) { |
471 ptr = rgb_data + ((14 - h) * 76) + x; | 472 ptr = rgb_data + ((14 - h) * 76) + x; |
472 *ptr = vis_scope_colors[h + 1]; | 473 *ptr = vis_scope_colors[h + 1]; |
473 }else{ | 474 }else{ |
474 ptr = rgb_data + ((14 - h) * (guint)(76 * 4 * aud_cfg->scale_factor)) + (guint)(x * aud_cfg->scale_factor); | 475 ptr = rgb_data + ((14 - h) * (guint)(76 * 4 * config.scale_factor)) + (guint)(x * aud_cfg->scale_factor); |
475 *ptr = vis_scope_colors[h + 1]; | 476 *ptr = vis_scope_colors[h + 1]; |
476 *(ptr + 1) = vis_scope_colors[h + 1]; | 477 *(ptr + 1) = vis_scope_colors[h + 1]; |
477 *(ptr + (guint)(76 * aud_cfg->scale_factor)) = vis_scope_colors[h + 1]; | 478 *(ptr + (guint)(76 * config.scale_factor)) = vis_scope_colors[h + 1]; |
478 *(ptr + (guint)(76 * aud_cfg->scale_factor)+1) = vis_scope_colors[h + 1]; | 479 *(ptr + (guint)(76 * config.scale_factor)+1) = vis_scope_colors[h + 1]; |
479 } | 480 } |
480 break; | 481 break; |
481 case SCOPE_LINE: | 482 case SCOPE_LINE: |
482 if (x != 74) { | 483 if (x != 74) { |
483 h = 14 - vis->data[x]; | 484 h = 14 - vis->data[x]; |
491 ptr = rgb_data + (h * 76) + x; | 492 ptr = rgb_data + (h * 76) + x; |
492 for (y = h; y <= h2; y++, ptr += 76) | 493 for (y = h; y <= h2; y++, ptr += 76) |
493 *ptr = vis_scope_colors[y - 2]; | 494 *ptr = vis_scope_colors[y - 2]; |
494 } | 495 } |
495 else{ | 496 else{ |
496 ptr = rgb_data + (h * (guint)(76 * 4 * aud_cfg->scale_factor)) + (guint)(x * aud_cfg->scale_factor); | 497 ptr = rgb_data + (h * (guint)(76 * 4 * config.scale_factor)) + (guint)(x * aud_cfg->scale_factor); |
497 for (y = h; y <= h2; y++, ptr += (guint)(76 * 4 * aud_cfg->scale_factor)) { | 498 for (y = h; y <= h2; y++, ptr += (guint)(76 * 4 * config.scale_factor)) { |
498 *ptr = vis_scope_colors[y - 2]; | 499 *ptr = vis_scope_colors[y - 2]; |
499 *(ptr + 1) = vis_scope_colors[y - 2]; | 500 *(ptr + 1) = vis_scope_colors[y - 2]; |
500 *(ptr + (guint)(76 * aud_cfg->scale_factor)) = vis_scope_colors[y - 2]; | 501 *(ptr + (guint)(76 * config.scale_factor)) = vis_scope_colors[y - 2]; |
501 *(ptr + (guint)(76 * aud_cfg->scale_factor)+1) = vis_scope_colors[y - 2]; | 502 *(ptr + (guint)(76 * config.scale_factor)+1) = vis_scope_colors[y - 2]; |
502 } | 503 } |
503 } | 504 } |
504 } | 505 } |
505 else { | 506 else { |
506 h = 14 - vis->data[x]; | 507 h = 14 - vis->data[x]; |
507 if (!vis->scaled) { | 508 if (!vis->scaled) { |
508 ptr = rgb_data + (h * 76) + x; | 509 ptr = rgb_data + (h * 76) + x; |
509 *ptr = vis_scope_colors[h + 1]; | 510 *ptr = vis_scope_colors[h + 1]; |
510 }else{ | 511 }else{ |
511 ptr = rgb_data + (h * (guint)(76 * 4 * aud_cfg->scale_factor)) + (guint)(x * aud_cfg->scale_factor); | 512 ptr = rgb_data + (h * (guint)(76 * 4 * config.scale_factor)) + (guint)(x * aud_cfg->scale_factor); |
512 *ptr = vis_scope_colors[h + 1]; | 513 *ptr = vis_scope_colors[h + 1]; |
513 *(ptr + 1) = vis_scope_colors[h + 1]; | 514 *(ptr + 1) = vis_scope_colors[h + 1]; |
514 *(ptr + (guint)(76 * aud_cfg->scale_factor)) = vis_scope_colors[h + 1]; | 515 *(ptr + (guint)(76 * config.scale_factor)) = vis_scope_colors[h + 1]; |
515 *(ptr + (guint)(76 * aud_cfg->scale_factor)+1) = vis_scope_colors[h + 1]; | 516 *(ptr + (guint)(76 * config.scale_factor)+1) = vis_scope_colors[h + 1]; |
516 } | 517 } |
517 } | 518 } |
518 break; | 519 break; |
519 case SCOPE_SOLID: | 520 case SCOPE_SOLID: |
520 h = 14 - vis->data[x]; | 521 h = 14 - vis->data[x]; |
528 if (!vis->scaled) { | 529 if (!vis->scaled) { |
529 ptr = rgb_data + (h * 76) + x; | 530 ptr = rgb_data + (h * 76) + x; |
530 for (y = h; y <= h2; y++, ptr += 76) | 531 for (y = h; y <= h2; y++, ptr += 76) |
531 *ptr = c; | 532 *ptr = c; |
532 }else{ | 533 }else{ |
533 ptr = rgb_data + (h * (guint)(76 * 4 * aud_cfg->scale_factor)) + (guint)(x * aud_cfg->scale_factor); | 534 ptr = rgb_data + (h * (guint)(76 * 4 * config.scale_factor)) + (guint)(x * aud_cfg->scale_factor); |
534 for (y = h; y <= h2; y++, ptr += (guint)(76 * 4 * aud_cfg->scale_factor)) { | 535 for (y = h; y <= h2; y++, ptr += (guint)(76 * 4 * config.scale_factor)) { |
535 *ptr = c; | 536 *ptr = c; |
536 *(ptr + 1) = c; | 537 *(ptr + 1) = c; |
537 *(ptr + (guint)(76 * aud_cfg->scale_factor)) = c; | 538 *(ptr + (guint)(76 * config.scale_factor)) = c; |
538 *(ptr + (guint)(76 * aud_cfg->scale_factor)+1) = c; | 539 *(ptr + (guint)(76 * config.scale_factor)+1) = c; |
539 } | 540 } |
540 } | 541 } |
541 break; | 542 break; |
542 } | 543 } |
543 } | 544 } |
544 } | 545 } |
545 | 546 |
546 GdkPixmap *obj = NULL; | 547 GdkPixmap *obj = NULL; |
547 GdkGC *gc; | 548 GdkGC *gc; |
548 obj = gdk_pixmap_new(NULL, vis->width*(vis->scaled ? aud_cfg->scale_factor : 1), vis->height*(vis->scaled ? aud_cfg->scale_factor : 1), gdk_rgb_get_visual()->depth); | 549 obj = gdk_pixmap_new(NULL, vis->width*(vis->scaled ? config.scale_factor : 1), vis->height*(vis->scaled ? aud_cfg->scale_factor : 1), gdk_rgb_get_visual()->depth); |
549 gc = gdk_gc_new(obj); | 550 gc = gdk_gc_new(obj); |
550 | 551 |
551 if (!vis->scaled) { | 552 if (!vis->scaled) { |
552 if (aud_cfg->vis_type == VIS_VOICEPRINT) { | 553 if (config.vis_type == VIS_VOICEPRINT) { |
553 gdk_draw_rgb_image(obj, gc, 0, 0, vis->width, vis->height, | 554 gdk_draw_rgb_image(obj, gc, 0, 0, vis->width, vis->height, |
554 GDK_RGB_DITHER_NORMAL, (guchar *) rgb_data, | 555 GDK_RGB_DITHER_NORMAL, (guchar *) rgb_data, |
555 76 * 3); | 556 76 * 3); |
556 } else { | 557 } else { |
557 gdk_draw_indexed_image(obj, gc, 0, 0, vis->width, vis->height, | 558 gdk_draw_indexed_image(obj, gc, 0, 0, vis->width, vis->height, |
558 GDK_RGB_DITHER_NORMAL, (guchar *) rgb_data, | 559 GDK_RGB_DITHER_NORMAL, (guchar *) rgb_data, |
559 76 , cmap); | 560 76 , cmap); |
560 } | 561 } |
561 } else { | 562 } else { |
562 if (aud_cfg->vis_type == VIS_VOICEPRINT) { | 563 if (config.vis_type == VIS_VOICEPRINT) { |
563 gdk_draw_rgb_image(obj, gc, 0 << 1, 0 << 1, | 564 gdk_draw_rgb_image(obj, gc, 0 << 1, 0 << 1, |
564 vis->width << 1, vis->height << 1, | 565 vis->width << 1, vis->height << 1, |
565 GDK_RGB_DITHER_NONE, (guchar *) rgb_data, | 566 GDK_RGB_DITHER_NONE, (guchar *) rgb_data, |
566 76 * 2 * 3); | 567 76 * 2 * 3); |
567 } else { | 568 } else { |
571 76 * 2 , cmap); | 572 76 * 2 , cmap); |
572 } | 573 } |
573 } | 574 } |
574 | 575 |
575 gdk_draw_drawable (widget->window, gc, obj, 0, 0, 0, 0, | 576 gdk_draw_drawable (widget->window, gc, obj, 0, 0, 0, 0, |
576 vis->width*(vis->scaled ? aud_cfg->scale_factor : 1), vis->height*(vis->scaled ? aud_cfg->scale_factor : 1)); | 577 vis->width*(vis->scaled ? config.scale_factor : 1), vis->height*(vis->scaled ? aud_cfg->scale_factor : 1)); |
577 g_object_unref(obj); | 578 g_object_unref(obj); |
578 g_object_unref(gc); | 579 g_object_unref(gc); |
579 gdk_rgb_cmap_free(cmap); | 580 gdk_rgb_cmap_free(cmap); |
580 return FALSE; | 581 return FALSE; |
581 } | 582 } |
582 | 583 |
583 static void ui_vis_toggle_scaled(UiVis *vis) { | 584 static void ui_vis_toggle_scaled(UiVis *vis) { |
584 GtkWidget *widget = GTK_WIDGET (vis); | 585 GtkWidget *widget = GTK_WIDGET (vis); |
585 vis->scaled = !vis->scaled; | 586 vis->scaled = !vis->scaled; |
586 | 587 |
587 gtk_widget_set_size_request(widget, vis->width*(vis->scaled ? aud_cfg->scale_factor : 1), vis->height*(vis->scaled ? aud_cfg->scale_factor : 1)); | 588 gtk_widget_set_size_request(widget, vis->width*(vis->scaled ? config.scale_factor : 1), vis->height*(vis->scaled ? aud_cfg->scale_factor : 1)); |
588 | 589 |
589 gtk_widget_queue_draw(GTK_WIDGET(vis)); | 590 gtk_widget_queue_draw(GTK_WIDGET(vis)); |
590 } | 591 } |
591 | 592 |
592 void ui_vis_draw_pixel(GtkWidget *widget, guchar* texture, gint x, gint y, guint8 colour) { | 593 void ui_vis_draw_pixel(GtkWidget *widget, guchar* texture, gint x, gint y, guint8 colour) { |
633 gint i; | 634 gint i; |
634 UiVis *vis = UI_VIS (widget); | 635 UiVis *vis = UI_VIS (widget); |
635 | 636 |
636 memset(voiceprint_data, 0, 16*76); | 637 memset(voiceprint_data, 0, 16*76); |
637 for (i = 0; i < 75; i++) { | 638 for (i = 0; i < 75; i++) { |
638 vis->data[i] = (aud_cfg->vis_type == VIS_SCOPE) ? 6 : 0; | 639 vis->data[i] = (config.vis_type == VIS_SCOPE) ? 6 : 0; |
639 vis->peak[i] = 0; | 640 vis->peak[i] = 0; |
640 } | 641 } |
641 } | 642 } |
642 | 643 |
643 void ui_vis_timeout_func(GtkWidget *widget, guchar * data) { | 644 void ui_vis_timeout_func(GtkWidget *widget, guchar * data) { |
654 else { | 655 else { |
655 g_timer_elapsed(timer, µs); | 656 g_timer_elapsed(timer, µs); |
656 if (micros > 14000) | 657 if (micros > 14000) |
657 g_timer_reset(timer); | 658 g_timer_reset(timer); |
658 } | 659 } |
659 if (aud_cfg->vis_type == VIS_ANALYZER) { | 660 if (config.vis_type == VIS_ANALYZER) { |
660 if (micros > 14000) | 661 if (micros > 14000) |
661 falloff = TRUE; | 662 falloff = TRUE; |
662 if (data || falloff) { | 663 if (data || falloff) { |
663 for (i = 0; i < 75; i++) { | 664 for (i = 0; i < 75; i++) { |
664 if (data && data[i] > vis->data[i]) { | 665 if (data && data[i] > vis->data[i]) { |
669 | 670 |
670 } | 671 } |
671 else if (vis->peak[i] > 0.0) { | 672 else if (vis->peak[i] > 0.0) { |
672 vis->peak[i] -= vis->peak_speed[i]; | 673 vis->peak[i] -= vis->peak_speed[i]; |
673 vis->peak_speed[i] *= | 674 vis->peak_speed[i] *= |
674 vis_pfalloff_speeds[aud_cfg->peaks_falloff]; | 675 vis_pfalloff_speeds[config.peaks_falloff]; |
675 if (vis->peak[i] < vis->data[i]) | 676 if (vis->peak[i] < vis->data[i]) |
676 vis->peak[i] = vis->data[i]; | 677 vis->peak[i] = vis->data[i]; |
677 if (vis->peak[i] < 0.0) | 678 if (vis->peak[i] < 0.0) |
678 vis->peak[i] = 0.0; | 679 vis->peak[i] = 0.0; |
679 } | 680 } |
680 } | 681 } |
681 else if (falloff) { | 682 else if (falloff) { |
682 if (vis->data[i] > 0.0) { | 683 if (vis->data[i] > 0.0) { |
683 vis->data[i] -= | 684 vis->data[i] -= |
684 vis_afalloff_speeds[aud_cfg->analyzer_falloff]; | 685 vis_afalloff_speeds[config.analyzer_falloff]; |
685 if (vis->data[i] < 0.0) | 686 if (vis->data[i] < 0.0) |
686 vis->data[i] = 0.0; | 687 vis->data[i] = 0.0; |
687 } | 688 } |
688 if (vis->peak[i] > 0.0) { | 689 if (vis->peak[i] > 0.0) { |
689 vis->peak[i] -= vis->peak_speed[i]; | 690 vis->peak[i] -= vis->peak_speed[i]; |
690 vis->peak_speed[i] *= | 691 vis->peak_speed[i] *= |
691 vis_pfalloff_speeds[aud_cfg->peaks_falloff]; | 692 vis_pfalloff_speeds[config.peaks_falloff]; |
692 if (vis->peak[i] < vis->data[i]) | 693 if (vis->peak[i] < vis->data[i]) |
693 vis->peak[i] = vis->data[i]; | 694 vis->peak[i] = vis->data[i]; |
694 if (vis->peak[i] < 0.0) | 695 if (vis->peak[i] < 0.0) |
695 vis->peak[i] = 0.0; | 696 vis->peak[i] = 0.0; |
696 } | 697 } |
697 } | 698 } |
698 } | 699 } |
699 } | 700 } |
700 } | 701 } |
701 else if (aud_cfg->vis_type == VIS_VOICEPRINT && data){ | 702 else if (config.vis_type == VIS_VOICEPRINT && data){ |
702 for(i = 0; i < 16; i++) | 703 for(i = 0; i < 16; i++) |
703 { | 704 { |
704 vis->data[i] = data[15 - i]; | 705 vis->data[i] = data[15 - i]; |
705 } | 706 } |
706 } | 707 } |
710 } | 711 } |
711 | 712 |
712 if (micros > 14000) { | 713 if (micros > 14000) { |
713 if (!vis->refresh_delay) { | 714 if (!vis->refresh_delay) { |
714 gtk_widget_queue_draw(widget); | 715 gtk_widget_queue_draw(widget); |
715 vis->refresh_delay = vis_redraw_delays[aud_cfg->vis_refresh]; | 716 vis->refresh_delay = vis_redraw_delays[config.vis_refresh]; |
716 } | 717 } |
717 vis->refresh_delay--; | 718 vis->refresh_delay--; |
718 } | 719 } |
719 } | 720 } |