Mercurial > audlegacy-plugins
annotate src/spectrum/spectrum.c @ 1416:e11d83ce8d16
amidiplug: cannot warn user with a UI message anymore if something in playback fails, cause the play func is in a different thread
author | Giacomo Lozito <james@develia.org> |
---|---|
date | Wed, 08 Aug 2007 20:25:13 +0200 |
parents | 761e17b23e0c |
children | e4b077cebfac |
rev | line source |
---|---|
147 | 1 /* Spectrum Analyzer Visualization Plugin for Audacious |
146
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
2 * |
147 | 3 * Copyright (C) 2006 William Pitcock |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1142
diff
changeset
|
4 * Copyright (C) 1998-2001 V�gv�lgyi Attila, Peter Alm, Mikael Alm, |
146
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
5 * Olle Hallnas, Thomas Nilsson and 4Front Technologies |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
6 * |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
7 * This program is free software; you can redistribute it and/or modify |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
8 * it under the terms of the GNU General Public License as published by |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
9 * the Free Software Foundation; either version 2 of the License, or |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
10 * (at your option) any later version. |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
11 * |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
15 * GNU General Public License for more details. |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
16 * |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
17 * You should have received a copy of the GNU General Public License |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
18 * along with this program; if not, write to the Free Software |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
20 */ |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
21 |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
22 #include "config.h" |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
23 |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
24 #include <gtk/gtk.h> |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
25 #include <math.h> |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
26 #include <audacious/plugin.h> |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
27 #include <audacious/util.h> |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1142
diff
changeset
|
28 #include <audacious/i18n.h> |
146
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
29 |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
30 #include "logo.xpm" |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
31 |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
32 /* WIDTH should be kept 256, this is the hardwired resolution of the |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
33 spectrum given by XMMS */ |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
34 #define WIDTH 256 |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
35 |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
36 /* HEIGHT can be modified at your pleasure */ |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
37 #define HEIGHT 128 |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
38 |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
39 /* Linearity of the amplitude scale (0.5 for linear, keep in [0.1, 0.9]) */ |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
40 #define d 0.33 |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
41 |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
42 /* Time factor of the band dinamics. 3 means that the coefficient of the |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
43 last value is half of the current one's. (see source) */ |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
44 #define tau 3 |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
45 |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
46 /* Factor used for the diffusion. 4 means that half of the height is |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
47 added to the neighbouring bars */ |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
48 #define dif 4 |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
49 |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
50 static GtkWidget *window = NULL,*area; |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
51 static GdkPixmap *bg_pixmap = NULL, *draw_pixmap = NULL, *bar = NULL; |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
52 static GdkGC *gc = NULL; |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
53 static gint16 bar_heights[WIDTH]; |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
54 /*static gint timeout_tag;*/ |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
55 static gdouble scale, x00, y00; |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
56 |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
57 static void fsanalyzer_init(void); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
58 static void fsanalyzer_cleanup(void); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
59 static void fsanalyzer_playback_start(void); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
60 static void fsanalyzer_playback_stop(void); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
61 static void fsanalyzer_render_freq(gint16 data[2][256]); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
62 |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
63 VisPlugin fsanalyzer_vp = { |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
64 NULL, |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
65 NULL, |
1142
b10c821f0b4e
[svn] - spectrum: convert to plugin2 architecture.
nenolod
parents:
1061
diff
changeset
|
66 "Spectrum Analyzer", |
146
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
67 0, |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1142
diff
changeset
|
68 1, |
146
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
69 fsanalyzer_init, /* init */ |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
70 fsanalyzer_cleanup, /* cleanup */ |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
71 NULL, /* about */ |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
72 NULL, /* configure */ |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
73 NULL, /* disable_plugin */ |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
74 fsanalyzer_playback_start, /* playback_start */ |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
75 fsanalyzer_playback_stop, /* playback_stop */ |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
76 NULL, /* render_pcm */ |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
77 fsanalyzer_render_freq /* render_freq */ |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
78 }; |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
79 |
1142
b10c821f0b4e
[svn] - spectrum: convert to plugin2 architecture.
nenolod
parents:
1061
diff
changeset
|
80 VisPlugin *spectrum_vplist[] = { &fsanalyzer_vp, NULL }; |
b10c821f0b4e
[svn] - spectrum: convert to plugin2 architecture.
nenolod
parents:
1061
diff
changeset
|
81 |
1395
761e17b23e0c
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
1325
diff
changeset
|
82 DECLARE_PLUGIN(spectrum, NULL, NULL, NULL, NULL, NULL, NULL, spectrum_vplist,NULL); |
146
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
83 |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
84 static void fsanalyzer_destroy_cb(GtkWidget *w,gpointer data) { |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
85 fsanalyzer_vp.disable_plugin(&fsanalyzer_vp); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
86 } |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
87 |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
88 static void fsanalyzer_init(void) { |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
89 GdkColor color; |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
90 int i; |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
91 |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
92 if(window) |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
93 return; |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
94 |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
95 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1142
diff
changeset
|
96 gtk_window_set_title(GTK_WINDOW(window), _("Spectrum Analyzer")); |
146
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
97 gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, FALSE); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
98 gtk_widget_realize(window); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
99 bg_pixmap = gdk_pixmap_create_from_xpm_d(window->window,NULL,NULL,logo_xpm); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
100 gdk_window_set_back_pixmap(window->window,bg_pixmap,0); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
101 g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(fsanalyzer_destroy_cb),NULL); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
102 g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_widget_destroyed), &window); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
103 gtk_widget_set_size_request(GTK_WIDGET(window), WIDTH, HEIGHT); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
104 gc = gdk_gc_new(window->window); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
105 draw_pixmap = gdk_pixmap_new(window->window,WIDTH,HEIGHT,gdk_rgb_get_visual()->depth); |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1142
diff
changeset
|
106 |
146
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
107 bar = gdk_pixmap_new(window->window,25, HEIGHT, gdk_rgb_get_visual()->depth); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
108 for(i = 0; i < HEIGHT / 2; i++) { |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
109 color.red = 0xFFFF; |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
110 color.green = ((i * 255) / (HEIGHT / 2)) << 8; |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
111 color.blue = 0; |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1142
diff
changeset
|
112 |
146
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
113 gdk_color_alloc(gdk_colormap_get_system(),&color); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
114 gdk_gc_set_foreground(gc,&color); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
115 gdk_draw_line(bar,gc,0,i,24,i); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
116 } |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
117 for(i = 0; i < HEIGHT / 2; i++) { |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
118 color.red = (255 - ((i * 255) / (HEIGHT / 2))) <<8; |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
119 color.green = 0xFFFF; |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
120 color.blue = 0; |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1142
diff
changeset
|
121 |
146
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
122 gdk_color_alloc(gdk_colormap_get_system(),&color); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
123 gdk_gc_set_foreground(gc,&color); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
124 gdk_draw_line(bar,gc,0,i + (HEIGHT / 2),24,i + (HEIGHT / 2)); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
125 } |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1142
diff
changeset
|
126 |
146
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
127 scale = HEIGHT / ( log((1 - d) / d) * 2 ); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
128 x00 = d*d*32768.0/(2 * d - 1); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
129 y00 = -log(-x00) * scale; |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
130 |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1142
diff
changeset
|
131 /* d=0.2, HEIGHT=128 |
146
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
132 scale = 46.1662413084; |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
133 x00 = -2184.53333333; |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
134 y00 = -354.979500941; |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
135 */ |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
136 |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
137 gdk_color_black(gdk_colormap_get_system(),&color); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
138 gdk_gc_set_foreground(gc,&color); |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1142
diff
changeset
|
139 |
146
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
140 area = gtk_drawing_area_new(); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
141 gtk_container_add(GTK_CONTAINER(window),area); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
142 gtk_widget_realize(area); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
143 gdk_window_set_back_pixmap(area->window,bg_pixmap,0); |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1142
diff
changeset
|
144 |
146
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
145 gtk_widget_show(area); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
146 gtk_widget_show(window); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
147 gdk_window_clear(window->window); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
148 gdk_window_clear(area->window); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
149 } |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
150 |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
151 static void fsanalyzer_cleanup(void) { |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
152 if(window) { |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
153 gtk_widget_destroy(window); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
154 } |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
155 if(gc) { |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
156 gdk_gc_unref(gc); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
157 gc = NULL; |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
158 } |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
159 if(bg_pixmap) { |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
160 gdk_pixmap_unref(bg_pixmap); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
161 bg_pixmap = NULL; |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
162 } |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
163 if(draw_pixmap) { |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
164 gdk_pixmap_unref(draw_pixmap); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
165 draw_pixmap = NULL; |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
166 } |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
167 if(bar) { |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
168 gdk_pixmap_unref(bar); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
169 bar = NULL; |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
170 } |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
171 } |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
172 |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
173 static gint draw_func(gpointer data) { |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
174 gint i; |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1142
diff
changeset
|
175 |
146
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
176 /* FIXME: should allow spare redrawing like the vis. in the main window */ |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
177 if(!window) { |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
178 /* timeout_tag = 0;*/ |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
179 return FALSE; |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
180 } |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1142
diff
changeset
|
181 |
146
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
182 GDK_THREADS_ENTER(); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
183 gdk_draw_rectangle(draw_pixmap, gc, TRUE, 0, 0, WIDTH, HEIGHT); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
184 |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
185 for(i = 0; i < WIDTH; i++) |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
186 gdk_draw_pixmap(draw_pixmap, gc, bar, 0, HEIGHT-1-bar_heights[i], i, HEIGHT-1-bar_heights[i], 1, bar_heights[i]); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
187 |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
188 gdk_window_clear(area->window); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
189 GDK_THREADS_LEAVE(); |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1142
diff
changeset
|
190 |
146
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
191 return TRUE; |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
192 } |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
193 |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
194 static void fsanalyzer_playback_start(void) { |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
195 if(window) { |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
196 gdk_window_set_back_pixmap(area->window,draw_pixmap,0); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
197 gdk_window_clear(area->window); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
198 } |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
199 } |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
200 |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
201 |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
202 static void fsanalyzer_playback_stop(void) { |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
203 if(GTK_WIDGET_REALIZED(area)) { |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
204 gdk_window_set_back_pixmap(area->window,bg_pixmap,0); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
205 gdk_window_clear(area->window); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
206 } |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
207 } |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
208 |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
209 static void fsanalyzer_render_freq(gint16 data[2][256]) { |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
210 gint i; |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
211 gdouble y; |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
212 |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
213 if(!window) |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
214 return; |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
215 |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
216 /* FIXME: can anything taken out of the main thread? */ |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
217 for (i = 0; i < WIDTH; i++) { |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
218 y = (gdouble)data[0][i] * (i + 1); /* Compensating the energy */ |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
219 y = ( log(y - x00) * scale + y00 ); /* Logarithmic amplitude */ |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
220 |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
221 y = ( (dif-2)*y + /* FIXME: conditionals should be rolled out of the loop */ |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
222 (i==0 ? y : bar_heights[i-1]) + |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
223 (i==WIDTH-1 ? y : bar_heights[i+1])) / dif; /* Add some diffusion */ |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
224 y = ((tau-1)*bar_heights[i] + y) / tau; /* Add some dynamics */ |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
225 bar_heights[i] = (gint16)y; |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
226 } |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
227 draw_func(NULL); |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
228 return; |
03cfb311eafd
[svn] - spectrum analyzer plugin based on blurscope and a little of xmms-finespectrum
nenolod
parents:
diff
changeset
|
229 } |