annotate audacious/vis.c @ 1429:a360afd8df52 trunk

[svn] Make annoying recursion that consistently returns wrong art, optional.
author nemo
date Mon, 24 Jul 2006 16:20:05 -0700
parents 0ee0b9b6db7e
children f12d7e208b43
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
1 /* BMP - Cross-platform multimedia player
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
2 * Copyright (C) 2003-2004 BMP development team.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
3 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
4 * Based on XMMS:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
5 * Copyright (C) 1998-2003 XMMS development team.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
6 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
10 * (at your option) any later version.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
11 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
15 * GNU General Public License for more details.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
16 *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
20 */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
21
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
22 #include "vis.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
23
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
24 #include <glib.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
25 #include <gdk/gdk.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
26 #include <string.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
27
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
28 #include "main.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
29 #include "skin.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
30 #include "widget.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
31
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
32 static const gfloat vis_afalloff_speeds[] = { 0.34, 0.5, 1.0, 1.3, 1.6 };
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
33 static const gfloat vis_pfalloff_speeds[] = { 1.2, 1.3, 1.4, 1.5, 1.6 };
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
34 static const gint vis_redraw_delays[] = { 1, 2, 4, 8 };
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
35 static const guint8 vis_scope_colors[] =
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
36 { 21, 21, 20, 20, 19, 19, 18, 19, 19, 20, 20, 21, 21 };
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
37
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
38 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
39 vis_timeout_func(Vis * vis, guchar * data)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
40 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
41 static GTimer *timer = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
42 gulong micros = 9999999;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
43 gboolean falloff = FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
44 gint i;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
45
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
46 if (!timer) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
47 timer = g_timer_new();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
48 g_timer_start(timer);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
49 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
50 else {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
51 g_timer_elapsed(timer, &micros);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
52 if (micros > 14000)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
53 g_timer_reset(timer);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
54
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
55 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
56
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
57 if (cfg.vis_type == VIS_ANALYZER) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
58 if (micros > 14000)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
59 falloff = TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
60 if (data || falloff) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
61 for (i = 0; i < 75; i++) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
62 if (data && data[i] > vis->vs_data[i]) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
63 vis->vs_data[i] = data[i];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
64 if (vis->vs_data[i] > vis->vs_peak[i]) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
65 vis->vs_peak[i] = vis->vs_data[i];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
66 vis->vs_peak_speed[i] = 0.01;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
67
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
68 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
69 else if (vis->vs_peak[i] > 0.0) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
70 vis->vs_peak[i] -= vis->vs_peak_speed[i];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
71 vis->vs_peak_speed[i] *=
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
72 vis_pfalloff_speeds[cfg.peaks_falloff];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
73 if (vis->vs_peak[i] < vis->vs_data[i])
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
74 vis->vs_peak[i] = vis->vs_data[i];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
75 if (vis->vs_peak[i] < 0.0)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
76 vis->vs_peak[i] = 0.0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
77 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
78 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
79 else if (falloff) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
80 if (vis->vs_data[i] > 0.0) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
81 vis->vs_data[i] -=
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
82 vis_afalloff_speeds[cfg.analyzer_falloff];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
83 if (vis->vs_data[i] < 0.0)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
84 vis->vs_data[i] = 0.0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
85 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
86 if (vis->vs_peak[i] > 0.0) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
87 vis->vs_peak[i] -= vis->vs_peak_speed[i];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
88 vis->vs_peak_speed[i] *=
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
89 vis_pfalloff_speeds[cfg.peaks_falloff];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
90 if (vis->vs_peak[i] < vis->vs_data[i])
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
91 vis->vs_peak[i] = vis->vs_data[i];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
92 if (vis->vs_peak[i] < 0.0)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
93 vis->vs_peak[i] = 0.0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
94 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
95 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
96 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
97 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
98 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
99 else if (data) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
100 for (i = 0; i < 75; i++)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
101 vis->vs_data[i] = data[i];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
102 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
103
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
104 if (micros > 14000) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
105 if (!vis->vs_refresh_delay) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
106 vis_draw((Widget *) vis);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
107 vis->vs_refresh_delay = vis_redraw_delays[cfg.vis_refresh];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
108
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
109 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
110 vis->vs_refresh_delay--;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
111 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
112 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
113
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
114 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
115 vis_draw(Widget * w)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
116 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
117 Vis *vis = (Vis *) w;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
118 gint x, y, h = 0, h2;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
119 guchar vis_color[24][3];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
120 guchar rgb_data[152 * 32], *ptr, c;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
121 guint32 colors[24];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
122 GdkRgbCmap *cmap;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
123
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
124 if (!vis->vs_widget.visible)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
125 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
126
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
127 skin_get_viscolor(bmp_active_skin, vis_color);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
128 for (y = 0; y < 24; y++) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
129 colors[y] =
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
130 vis_color[y][0] << 16 | vis_color[y][1] << 8 | vis_color[y][2];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
131 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
132 cmap = gdk_rgb_cmap_new(colors, 24);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
133
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
134 memset(rgb_data, 0, 76 * 16);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
135 for (y = 1; y < 16; y += 2) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
136 ptr = rgb_data + (y * 76);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
137 for (x = 0; x < 76; x += 2, ptr += 2)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
138 *ptr = 1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
139 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
140 if (cfg.vis_type == VIS_ANALYZER) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
141 for (x = 0; x < 75; x++) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
142 if (cfg.analyzer_type == ANALYZER_BARS && (x % 4) == 0)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
143 h = vis->vs_data[x >> 2];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
144 else if (cfg.analyzer_type == ANALYZER_LINES)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
145 h = vis->vs_data[x];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
146 if (h && (cfg.analyzer_type == ANALYZER_LINES ||
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
147 (x % 4) != 3)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
148 ptr = rgb_data + ((16 - h) * 76) + x;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
149 switch (cfg.analyzer_mode) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
150 case ANALYZER_NORMAL:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
151 for (y = 0; y < h; y++, ptr += 76)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
152 *ptr = 18 - h + y;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
153 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
154 case ANALYZER_FIRE:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
155 for (y = 0; y < h; y++, ptr += 76)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
156 *ptr = y + 2;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
157 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
158 case ANALYZER_VLINES:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
159 for (y = 0; y < h; y++, ptr += 76)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
160 *ptr = 18 - h;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
161 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
162 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
163 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
164 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
165 if (cfg.analyzer_peaks) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
166 for (x = 0; x < 75; x++) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
167 if (cfg.analyzer_type == ANALYZER_BARS && (x % 4) == 0)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
168 h = vis->vs_peak[x >> 2];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
169 else if (cfg.analyzer_type == ANALYZER_LINES)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
170 h = vis->vs_peak[x];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
171 if (h
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
172 && (cfg.analyzer_type == ANALYZER_LINES
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
173 || (x % 4) != 3))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
174 rgb_data[(16 - h) * 76 + x] = 23;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
175 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
176 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
177 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
178 else if (cfg.vis_type == VIS_SCOPE) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
179 for (x = 0; x < 75; x++) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
180 switch (cfg.scope_mode) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
181 case SCOPE_DOT:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
182 h = vis->vs_data[x];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
183 ptr = rgb_data + ((15 - h) * 76) + x;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
184 *ptr = vis_scope_colors[h];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
185 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
186 case SCOPE_LINE:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
187 if (x != 74) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
188 h = 15 - vis->vs_data[x];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
189 h2 = 15 - vis->vs_data[x + 1];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
190 if (h > h2) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
191 y = h;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
192 h = h2;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
193 h2 = y;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
194 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
195 ptr = rgb_data + (h * 76) + x;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
196 for (y = h; y <= h2; y++, ptr += 76)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
197 *ptr = vis_scope_colors[y - 3];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
198
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
199 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
200 else {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
201 h = 15 - vis->vs_data[x];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
202 ptr = rgb_data + (h * 76) + x;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
203 *ptr = vis_scope_colors[h];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
204 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
205 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
206 case SCOPE_SOLID:
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
207 h = 15 - vis->vs_data[x];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
208 h2 = 9;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
209 c = vis_scope_colors[(gint) vis->vs_data[x]];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
210 if (h > h2) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
211 y = h;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
212 h = h2;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
213 h2 = y;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
214 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
215 ptr = rgb_data + (h * 76) + x;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
216 for (y = h; y <= h2; y++, ptr += 76)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
217 *ptr = c;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
218 break;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
219 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
220 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
221 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
222
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
223 /* FIXME: The check "shouldn't" be neccessary? */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
224 /* if (GTK_IS_WINDOW(vis->vs_window)) { */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
225 GDK_THREADS_ENTER();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
226 gdk_draw_indexed_image(vis->vs_window, vis->vs_widget.gc,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
227 vis->vs_widget.x, vis->vs_widget.y,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
228 vis->vs_widget.width, vis->vs_widget.height,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
229 GDK_RGB_DITHER_NORMAL, (guchar *) rgb_data,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
230 76, cmap);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
231 GDK_THREADS_LEAVE();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
232 /* } else {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
233 vis->vs_window = mainwin->window;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
234 GDK_THREADS_ENTER();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
235 gdk_draw_indexed_image(vis->vs_window, vis->vs_widget.gc,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
236 vis->vs_widget.x, vis->vs_widget.y,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
237 vis->vs_widget.width, vis->vs_widget.height,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
238 GDK_RGB_DITHER_NORMAL, (guchar *) rgb_data,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
239 76, cmap);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
240 GDK_THREADS_LEAVE();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
241 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
242 */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
243
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
244 gdk_rgb_cmap_free(cmap);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
245 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
246
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
247 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
248 vis_clear_data(Vis * vis)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
249 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
250 gint i;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
251
192
0ee0b9b6db7e [svn] headless now working, use --headless if you wish to experiment.
nenolod
parents: 0
diff changeset
252 if (!vis)
0ee0b9b6db7e [svn] headless now working, use --headless if you wish to experiment.
nenolod
parents: 0
diff changeset
253 return;
0ee0b9b6db7e [svn] headless now working, use --headless if you wish to experiment.
nenolod
parents: 0
diff changeset
254
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
255 for (i = 0; i < 75; i++) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
256 vis->vs_data[i] = (cfg.vis_type == VIS_SCOPE) ? 6 : 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
257 vis->vs_peak[i] = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
258 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
259 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
260
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
261 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
262 vis_clear(Vis * vis)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
263 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
264 gdk_window_clear_area(vis->vs_window, vis->vs_widget.x,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
265 vis->vs_widget.y, vis->vs_widget.width,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
266 vis->vs_widget.height);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
267 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
268
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
269 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
270 vis_set_window(Vis * vis, GdkWindow * window)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
271 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
272 vis->vs_window = window;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
273 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
274
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
275 Vis *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
276 create_vis(GList ** wlist,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
277 GdkPixmap * parent,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
278 GdkWindow * window,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
279 GdkGC * gc,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
280 gint x, gint y,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
281 gint width)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
282 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
283 Vis *vis;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
284
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
285 vis = g_new0(Vis, 1);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
286
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
287 widget_init(&vis->vs_widget, parent, gc, x, y, width, 16, 1);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
288 widget_list_add(wlist, WIDGET(vis));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
289
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
290 return vis;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
291 }