Mercurial > audlegacy
annotate audacious/widgets/vis.c @ 2188:9d06e177eeb1 trunk
[svn] - Fixed voiceprint scroll bug for stopped playback
- Made doublesize voiceprint look like it should
| author | marvin |
|---|---|
| date | Wed, 20 Dec 2006 13:05:57 -0800 |
| parents | 65ca93cd72bf |
| children | b9f60fcdf6cc |
| rev | line source |
|---|---|
| 1653 | 1 /* BMP - Cross-platform multimedia player |
| 2 * Copyright (C) 2003-2004 BMP development team. | |
| 3 * | |
| 4 * Based on XMMS: | |
| 5 * Copyright (C) 1998-2003 XMMS development team. | |
| 6 * | |
| 7 * This program is free software; you can redistribute it and/or modify | |
| 8 * it under the terms of the GNU General Public License as published by | |
| 9 * the Free Software Foundation; either version 2 of the License, or | |
| 10 * (at your option) any later version. | |
| 11 * | |
| 12 * This program is distributed in the hope that it will be useful, | |
| 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 15 * GNU General Public License for more details. | |
| 16 * | |
| 17 * You should have received a copy of the GNU General Public License | |
| 18 * along with this program; if not, write to the Free Software | |
| 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
| 20 */ | |
| 21 | |
| 22 #include "widgetcore.h" | |
| 23 | |
| 24 #include <glib.h> | |
| 25 #include <gdk/gdk.h> | |
| 26 #include <string.h> | |
| 27 | |
| 28 #include "main.h" | |
| 29 #include "skin.h" | |
| 30 #include "widget.h" | |
| 31 | |
| 32 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 gint vis_redraw_delays[] = { 1, 2, 4, 8 }; | |
| 35 static const guint8 vis_scope_colors[] = | |
| 36 { 21, 21, 20, 20, 19, 19, 18, 19, 19, 20, 20, 21, 21 }; | |
|
2161
c12319817d7e
[svn] - patch to add a scrolling voiceprint to the mini visualizer.
nenolod
parents:
1938
diff
changeset
|
37 static guint8 vs_data_ext[1216]; |
|
c12319817d7e
[svn] - patch to add a scrolling voiceprint to the mini visualizer.
nenolod
parents:
1938
diff
changeset
|
38 |
| 1653 | 39 |
| 40 void | |
| 41 vis_timeout_func(Vis * vis, guchar * data) | |
| 42 { | |
| 43 static GTimer *timer = NULL; | |
| 44 gulong micros = 9999999; | |
| 45 gboolean falloff = FALSE; | |
|
2161
c12319817d7e
[svn] - patch to add a scrolling voiceprint to the mini visualizer.
nenolod
parents:
1938
diff
changeset
|
46 gint i, n; |
| 1653 | 47 |
| 48 if (!timer) { | |
| 49 timer = g_timer_new(); | |
| 50 g_timer_start(timer); | |
| 51 } | |
| 52 else { | |
| 53 g_timer_elapsed(timer, µs); | |
| 54 if (micros > 14000) | |
| 55 g_timer_reset(timer); | |
| 56 | |
| 57 } | |
| 58 | |
| 59 if (cfg.vis_type == VIS_ANALYZER) { | |
| 60 if (micros > 14000) | |
| 61 falloff = TRUE; | |
| 62 if (data || falloff) { | |
| 63 for (i = 0; i < 75; i++) { | |
| 64 if (data && data[i] > vis->vs_data[i]) { | |
| 65 vis->vs_data[i] = data[i]; | |
| 66 if (vis->vs_data[i] > vis->vs_peak[i]) { | |
| 67 vis->vs_peak[i] = vis->vs_data[i]; | |
| 68 vis->vs_peak_speed[i] = 0.01; | |
| 69 | |
| 70 } | |
| 71 else if (vis->vs_peak[i] > 0.0) { | |
| 72 vis->vs_peak[i] -= vis->vs_peak_speed[i]; | |
| 73 vis->vs_peak_speed[i] *= | |
| 74 vis_pfalloff_speeds[cfg.peaks_falloff]; | |
| 75 if (vis->vs_peak[i] < vis->vs_data[i]) | |
| 76 vis->vs_peak[i] = vis->vs_data[i]; | |
| 77 if (vis->vs_peak[i] < 0.0) | |
| 78 vis->vs_peak[i] = 0.0; | |
| 79 } | |
| 80 } | |
| 81 else if (falloff) { | |
| 82 if (vis->vs_data[i] > 0.0) { | |
| 83 vis->vs_data[i] -= | |
| 84 vis_afalloff_speeds[cfg.analyzer_falloff]; | |
| 85 if (vis->vs_data[i] < 0.0) | |
| 86 vis->vs_data[i] = 0.0; | |
| 87 } | |
| 88 if (vis->vs_peak[i] > 0.0) { | |
| 89 vis->vs_peak[i] -= vis->vs_peak_speed[i]; | |
| 90 vis->vs_peak_speed[i] *= | |
| 91 vis_pfalloff_speeds[cfg.peaks_falloff]; | |
| 92 if (vis->vs_peak[i] < vis->vs_data[i]) | |
| 93 vis->vs_peak[i] = vis->vs_data[i]; | |
| 94 if (vis->vs_peak[i] < 0.0) | |
| 95 vis->vs_peak[i] = 0.0; | |
| 96 } | |
| 97 } | |
| 98 } | |
| 99 } | |
| 100 } | |
|
2161
c12319817d7e
[svn] - patch to add a scrolling voiceprint to the mini visualizer.
nenolod
parents:
1938
diff
changeset
|
101 else if (cfg.vis_type == VIS_VOICEPRINT && data){ |
|
c12319817d7e
[svn] - patch to add a scrolling voiceprint to the mini visualizer.
nenolod
parents:
1938
diff
changeset
|
102 for(i = 0; i < 16; i++) |
|
c12319817d7e
[svn] - patch to add a scrolling voiceprint to the mini visualizer.
nenolod
parents:
1938
diff
changeset
|
103 { |
|
2179
8bdcac47760b
[svn] Keep the voiceprint inside the range for the theme.
marvin
parents:
2171
diff
changeset
|
104 /*The color palette is in the range [0-17]. This makes sure we stay there.*/ |
|
8bdcac47760b
[svn] Keep the voiceprint inside the range for the theme.
marvin
parents:
2171
diff
changeset
|
105 vis->vs_data[i] = data[15 - i] > 17 ? 17 : data[15-i]; |
|
2161
c12319817d7e
[svn] - patch to add a scrolling voiceprint to the mini visualizer.
nenolod
parents:
1938
diff
changeset
|
106 } |
|
c12319817d7e
[svn] - patch to add a scrolling voiceprint to the mini visualizer.
nenolod
parents:
1938
diff
changeset
|
107 } |
| 1653 | 108 else if (data) { |
| 109 for (i = 0; i < 75; i++) | |
| 110 vis->vs_data[i] = data[i]; | |
| 111 } | |
| 112 | |
| 113 if (micros > 14000) { | |
| 114 if (!vis->vs_refresh_delay) { | |
| 115 vis_draw((Widget *) vis); | |
| 116 vis->vs_refresh_delay = vis_redraw_delays[cfg.vis_refresh]; | |
| 117 | |
| 118 } | |
| 119 vis->vs_refresh_delay--; | |
| 120 } | |
| 121 } | |
| 122 | |
| 123 void | |
| 124 vis_draw(Widget * w) | |
| 125 { | |
| 126 Vis *vis = (Vis *) w; | |
| 127 gint x, y, h = 0, h2; | |
| 128 guchar vis_color[24][3]; | |
| 129 guchar rgb_data[152 * 32], *ptr, c; | |
| 130 guint32 colors[24]; | |
| 131 GdkRgbCmap *cmap; | |
| 132 | |
| 133 if (!vis->vs_widget.visible) | |
| 134 return; | |
| 135 | |
| 136 skin_get_viscolor(bmp_active_skin, vis_color); | |
| 137 for (y = 0; y < 24; y++) { | |
| 138 colors[y] = | |
| 139 vis_color[y][0] << 16 | vis_color[y][1] << 8 | vis_color[y][2]; | |
| 140 } | |
| 141 cmap = gdk_rgb_cmap_new(colors, 24); | |
| 142 | |
| 1938 | 143 if (!vis->vs_doublesize) { |
| 144 memset(rgb_data, 0, 76 * 16); | |
| 145 for (y = 1; y < 16; y += 2) { | |
| 146 ptr = rgb_data + (y * 76); | |
| 147 for (x = 0; x < 76; x += 2, ptr += 2) | |
| 148 *ptr = 1; | |
| 149 } | |
| 150 if (cfg.vis_type == VIS_ANALYZER) { | |
| 151 for (x = 0; x < 75; x++) { | |
| 152 if (cfg.analyzer_type == ANALYZER_BARS && (x % 4) == 0) | |
| 153 h = vis->vs_data[x >> 2]; | |
| 154 else if (cfg.analyzer_type == ANALYZER_LINES) | |
| 155 h = vis->vs_data[x]; | |
| 156 if (h && (cfg.analyzer_type == ANALYZER_LINES || | |
| 157 (x % 4) != 3)) { | |
| 158 ptr = rgb_data + ((16 - h) * 76) + x; | |
| 159 switch (cfg.analyzer_mode) { | |
| 160 case ANALYZER_NORMAL: | |
| 161 for (y = 0; y < h; y++, ptr += 76) | |
| 162 *ptr = 18 - h + y; | |
| 163 break; | |
| 164 case ANALYZER_FIRE: | |
| 165 for (y = 0; y < h; y++, ptr += 76) | |
| 166 *ptr = y + 2; | |
| 167 break; | |
| 168 case ANALYZER_VLINES: | |
| 169 for (y = 0; y < h; y++, ptr += 76) | |
| 170 *ptr = 18 - h; | |
| 171 break; | |
| 172 } | |
| 173 } | |
| 174 } | |
| 175 if (cfg.analyzer_peaks) { | |
| 176 for (x = 0; x < 75; x++) { | |
| 177 if (cfg.analyzer_type == ANALYZER_BARS && (x % 4) == 0) | |
| 178 h = vis->vs_peak[x >> 2]; | |
| 179 else if (cfg.analyzer_type == ANALYZER_LINES) | |
| 180 h = vis->vs_peak[x]; | |
| 181 if (h | |
| 182 && (cfg.analyzer_type == ANALYZER_LINES | |
| 183 || (x % 4) != 3)) | |
| 184 rgb_data[(16 - h) * 76 + x] = 23; | |
| 1653 | 185 } |
| 186 } | |
| 187 } | |
|
2161
c12319817d7e
[svn] - patch to add a scrolling voiceprint to the mini visualizer.
nenolod
parents:
1938
diff
changeset
|
188 else if (cfg.vis_type == VIS_VOICEPRINT) { |
|
2188
9d06e177eeb1
[svn] - Fixed voiceprint scroll bug for stopped playback
marvin
parents:
2181
diff
changeset
|
189 if(!bmp_playback_get_paused() && bmp_playback_get_playing()){/*Don't scroll when it's paused or stopped*/ |
|
2181
65ca93cd72bf
[svn] - Added vis gradient to Ivory skin. With any luck Aerdan won't break my legs :)
marvin
parents:
2179
diff
changeset
|
190 for (y = 0; y < 16; y ++) |
|
65ca93cd72bf
[svn] - Added vis gradient to Ivory skin. With any luck Aerdan won't break my legs :)
marvin
parents:
2179
diff
changeset
|
191 for (x = 74; x > 0; x--) |
|
2161
c12319817d7e
[svn] - patch to add a scrolling voiceprint to the mini visualizer.
nenolod
parents:
1938
diff
changeset
|
192 vs_data_ext[x + (y * 76)] = vs_data_ext[x-1+(y*76)]; |
|
2181
65ca93cd72bf
[svn] - Added vis gradient to Ivory skin. With any luck Aerdan won't break my legs :)
marvin
parents:
2179
diff
changeset
|
193 for(y=0;y<16;y++) |
|
65ca93cd72bf
[svn] - Added vis gradient to Ivory skin. With any luck Aerdan won't break my legs :)
marvin
parents:
2179
diff
changeset
|
194 vs_data_ext[y * 76] = vis->vs_data[y]; |
|
2161
c12319817d7e
[svn] - patch to add a scrolling voiceprint to the mini visualizer.
nenolod
parents:
1938
diff
changeset
|
195 } |
|
c12319817d7e
[svn] - patch to add a scrolling voiceprint to the mini visualizer.
nenolod
parents:
1938
diff
changeset
|
196 memcpy(rgb_data, vs_data_ext,1216); |
|
c12319817d7e
[svn] - patch to add a scrolling voiceprint to the mini visualizer.
nenolod
parents:
1938
diff
changeset
|
197 } |
| 1938 | 198 else if (cfg.vis_type == VIS_SCOPE) { |
| 1653 | 199 for (x = 0; x < 75; x++) { |
| 1938 | 200 switch (cfg.scope_mode) { |
| 201 case SCOPE_DOT: | |
| 202 h = vis->vs_data[x]; | |
| 203 ptr = rgb_data + ((15 - h) * 76) + x; | |
| 204 *ptr = vis_scope_colors[h]; | |
| 205 break; | |
| 206 case SCOPE_LINE: | |
| 207 if (x != 74) { | |
| 208 h = 15 - vis->vs_data[x]; | |
| 209 h2 = 15 - vis->vs_data[x + 1]; | |
| 210 if (h > h2) { | |
| 211 y = h; | |
| 212 h = h2; | |
| 213 h2 = y; | |
| 214 } | |
| 215 ptr = rgb_data + (h * 76) + x; | |
| 216 for (y = h; y <= h2; y++, ptr += 76) | |
| 217 *ptr = vis_scope_colors[y - 3]; | |
| 218 | |
| 219 } | |
| 220 else { | |
| 221 h = 15 - vis->vs_data[x]; | |
| 222 ptr = rgb_data + (h * 76) + x; | |
| 223 *ptr = vis_scope_colors[h]; | |
| 224 } | |
| 225 break; | |
| 226 case SCOPE_SOLID: | |
| 1653 | 227 h = 15 - vis->vs_data[x]; |
| 1938 | 228 h2 = 9; |
| 229 c = vis_scope_colors[(gint) vis->vs_data[x]]; | |
| 1653 | 230 if (h > h2) { |
| 231 y = h; | |
| 232 h = h2; | |
| 233 h2 = y; | |
| 234 } | |
| 235 ptr = rgb_data + (h * 76) + x; | |
| 236 for (y = h; y <= h2; y++, ptr += 76) | |
| 1938 | 237 *ptr = c; |
| 238 break; | |
| 239 } | |
| 240 } | |
| 241 } | |
| 242 | |
| 243 /* FIXME: The check "shouldn't" be neccessary? */ | |
| 244 /* if (GTK_IS_WINDOW(vis->vs_window)) { */ | |
| 245 GDK_THREADS_ENTER(); | |
| 246 gdk_draw_indexed_image(vis->vs_window, vis->vs_widget.gc, | |
| 247 vis->vs_widget.x, vis->vs_widget.y, | |
| 248 vis->vs_widget.width, vis->vs_widget.height, | |
| 249 GDK_RGB_DITHER_NORMAL, (guchar *) rgb_data, | |
| 250 76, cmap); | |
| 251 GDK_THREADS_LEAVE(); | |
| 252 /* } else { | |
| 253 vis->vs_window = mainwin->window; | |
| 254 GDK_THREADS_ENTER(); | |
| 255 gdk_draw_indexed_image(vis->vs_window, vis->vs_widget.gc, | |
| 256 vis->vs_widget.x, vis->vs_widget.y, | |
| 257 vis->vs_widget.width, vis->vs_widget.height, | |
| 258 GDK_RGB_DITHER_NORMAL, (guchar *) rgb_data, | |
| 259 76, cmap); | |
| 260 GDK_THREADS_LEAVE(); | |
| 261 } | |
| 262 */ | |
| 263 } | |
| 264 else { | |
| 265 memset(rgb_data, 0, 152 * 32); | |
| 266 for (y = 1; y < 16; y += 2) { | |
| 267 ptr = rgb_data + (y * 304); | |
| 268 for (x = 0; x < 76; x += 2, ptr += 4) { | |
| 269 *ptr = 1; | |
| 270 *(ptr + 1) = 1; | |
| 271 *(ptr + 152) = 1; | |
| 272 *(ptr + 153) = 1; | |
| 273 } | |
| 274 } | |
| 275 if (cfg.vis_type == VIS_ANALYZER) { | |
| 276 for (x = 0; x < 75; x++) { | |
| 277 if (cfg.analyzer_type == ANALYZER_BARS && (x % 4) == 0) | |
| 278 h = vis->vs_data[x >> 2]; | |
| 279 else if (cfg.analyzer_type == ANALYZER_LINES) | |
| 280 h = vis->vs_data[x]; | |
| 281 if (h | |
| 282 && (cfg.analyzer_type == ANALYZER_LINES | |
| 283 || (x % 4) != 3)) { | |
| 284 ptr = rgb_data + ((16 - h) * 304) + (x << 1); | |
| 285 switch (cfg.analyzer_mode) { | |
| 286 case ANALYZER_NORMAL: | |
| 287 for (y = 0; y < h; y++, ptr += 304) { | |
| 288 *ptr = 18 - h + y; | |
| 289 *(ptr + 1) = 18 - h + y; | |
| 290 *(ptr + 152) = 18 - h + y; | |
| 291 *(ptr + 153) = 18 - h + y; | |
| 292 } | |
| 293 break; | |
| 294 case ANALYZER_FIRE: | |
| 295 for (y = 0; y < h; y++, ptr += 304) { | |
| 296 *ptr = y + 2; | |
| 297 *(ptr + 1) = y + 2; | |
| 298 *(ptr + 152) = y + 2; | |
| 299 *(ptr + 153) = y + 2; | |
| 300 } | |
| 301 break; | |
| 302 case ANALYZER_VLINES: | |
| 303 for (y = 0; y < h; y++, ptr += 304) { | |
| 304 *ptr = 18 - h; | |
| 305 *(ptr + 1) = 18 - h; | |
| 306 *(ptr + 152) = 18 - h; | |
| 307 *(ptr + 153) = 18 - h; | |
| 308 } | |
| 309 | |
| 310 break; | |
| 311 } | |
| 1653 | 312 |
| 313 } | |
| 1938 | 314 } |
| 315 if (cfg.analyzer_peaks) { | |
| 316 | |
| 317 for (x = 0; x < 75; x++) { | |
| 318 if (cfg.analyzer_type == ANALYZER_BARS && (x % 4) == 0) | |
| 319 h = vis->vs_peak[x >> 2]; | |
| 320 else if (cfg.analyzer_type == ANALYZER_LINES) | |
| 321 h = vis->vs_peak[x]; | |
| 322 | |
| 323 if (h | |
| 324 && (cfg.analyzer_type == ANALYZER_LINES | |
| 325 || (x % 4) != 3)) { | |
| 326 ptr = rgb_data + (16 - h) * 304 + (x << 1); | |
| 327 *ptr = 23; | |
| 328 *(ptr + 1) = 23; | |
| 329 *(ptr + 152) = 23; | |
| 330 *(ptr + 153) = 23; | |
| 331 } | |
| 1653 | 332 } |
| 333 } | |
| 334 } | |
|
2161
c12319817d7e
[svn] - patch to add a scrolling voiceprint to the mini visualizer.
nenolod
parents:
1938
diff
changeset
|
335 else if (cfg.vis_type == VIS_VOICEPRINT) { |
|
2188
9d06e177eeb1
[svn] - Fixed voiceprint scroll bug for stopped playback
marvin
parents:
2181
diff
changeset
|
336 if(!bmp_playback_get_paused() && bmp_playback_get_playing()){/*Don't scroll when it's paused or stopped*/ |
|
9d06e177eeb1
[svn] - Fixed voiceprint scroll bug for stopped playback
marvin
parents:
2181
diff
changeset
|
337 for (y = 0; y < 16; y ++) |
|
2181
65ca93cd72bf
[svn] - Added vis gradient to Ivory skin. With any luck Aerdan won't break my legs :)
marvin
parents:
2179
diff
changeset
|
338 for (x = 74; x > 0; x--) |
|
65ca93cd72bf
[svn] - Added vis gradient to Ivory skin. With any luck Aerdan won't break my legs :)
marvin
parents:
2179
diff
changeset
|
339 vs_data_ext[x + y * 76] = vs_data_ext[x - 1 + y * 76]; |
|
65ca93cd72bf
[svn] - Added vis gradient to Ivory skin. With any luck Aerdan won't break my legs :)
marvin
parents:
2179
diff
changeset
|
340 for(y=0;y<16;y++) |
|
65ca93cd72bf
[svn] - Added vis gradient to Ivory skin. With any luck Aerdan won't break my legs :)
marvin
parents:
2179
diff
changeset
|
341 vs_data_ext[y * 76] = vis->vs_data[y]; |
|
65ca93cd72bf
[svn] - Added vis gradient to Ivory skin. With any luck Aerdan won't break my legs :)
marvin
parents:
2179
diff
changeset
|
342 } |
|
2188
9d06e177eeb1
[svn] - Fixed voiceprint scroll bug for stopped playback
marvin
parents:
2181
diff
changeset
|
343 for (y = 0; y < 16; y ++) { |
|
2161
c12319817d7e
[svn] - patch to add a scrolling voiceprint to the mini visualizer.
nenolod
parents:
1938
diff
changeset
|
344 for (x = 74; x > 0; x--) |
|
c12319817d7e
[svn] - patch to add a scrolling voiceprint to the mini visualizer.
nenolod
parents:
1938
diff
changeset
|
345 { |
| 2171 | 346 ptr = rgb_data + (x << 1) + y * 304; |
|
2188
9d06e177eeb1
[svn] - Fixed voiceprint scroll bug for stopped playback
marvin
parents:
2181
diff
changeset
|
347 /*draw a 2x2 area with the same data*/ |
|
9d06e177eeb1
[svn] - Fixed voiceprint scroll bug for stopped playback
marvin
parents:
2181
diff
changeset
|
348 *ptr = vs_data_ext[x + y * 76]; |
|
9d06e177eeb1
[svn] - Fixed voiceprint scroll bug for stopped playback
marvin
parents:
2181
diff
changeset
|
349 *(ptr + 1) = vs_data_ext[x + y * 76]; |
|
9d06e177eeb1
[svn] - Fixed voiceprint scroll bug for stopped playback
marvin
parents:
2181
diff
changeset
|
350 *(ptr + 152) = vs_data_ext[x + y * 76]; |
|
9d06e177eeb1
[svn] - Fixed voiceprint scroll bug for stopped playback
marvin
parents:
2181
diff
changeset
|
351 *(ptr + 153) = vs_data_ext[x + y * 76]; |
|
2161
c12319817d7e
[svn] - patch to add a scrolling voiceprint to the mini visualizer.
nenolod
parents:
1938
diff
changeset
|
352 } |
|
c12319817d7e
[svn] - patch to add a scrolling voiceprint to the mini visualizer.
nenolod
parents:
1938
diff
changeset
|
353 } |
|
c12319817d7e
[svn] - patch to add a scrolling voiceprint to the mini visualizer.
nenolod
parents:
1938
diff
changeset
|
354 } |
| 1938 | 355 else if (cfg.vis_type == VIS_SCOPE) { |
| 356 for (x = 0; x < 75; x++) { | |
| 357 switch (cfg.scope_mode) { | |
| 358 case SCOPE_DOT: | |
| 359 h = vis->vs_data[x]; | |
| 360 ptr = rgb_data + ((15 - h) * 304) + (x << 1); | |
| 361 *ptr = vis_scope_colors[h]; | |
| 362 *(ptr + 1) = vis_scope_colors[h]; | |
| 363 *(ptr + 152) = vis_scope_colors[h]; | |
| 364 *(ptr + 153) = vis_scope_colors[h]; | |
| 365 break; | |
| 366 case SCOPE_LINE: | |
| 367 if (x != 74) { | |
| 368 h = 15 - vis->vs_data[x]; | |
| 369 h2 = 15 - vis->vs_data[x + 1]; | |
| 370 if (h > h2) { | |
| 371 y = h; | |
| 372 h = h2; | |
| 373 h2 = y; | |
| 374 } | |
| 375 ptr = rgb_data + (h * 304) + (x << 1); | |
| 376 for (y = h; y <= h2; y++, ptr += 304) { | |
| 377 *ptr = vis_scope_colors[y - 3]; | |
| 378 *(ptr + 1) = vis_scope_colors[y - 3]; | |
| 379 *(ptr + 152) = vis_scope_colors[y - 3]; | |
| 380 *(ptr + 153) = vis_scope_colors[y - 3]; | |
| 381 } | |
| 382 } | |
| 383 else { | |
| 384 h = 15 - vis->vs_data[x]; | |
| 385 ptr = rgb_data + (h * 304) + (x << 1); | |
| 386 *ptr = vis_scope_colors[h]; | |
| 387 *(ptr + 1) = vis_scope_colors[h]; | |
| 388 *(ptr + 152) = vis_scope_colors[h]; | |
| 389 *(ptr + 153) = vis_scope_colors[h]; | |
| 390 } | |
| 391 break; | |
| 392 case SCOPE_SOLID: | |
| 393 h = 15 - vis->vs_data[x]; | |
| 394 h2 = 9; | |
| 395 c = vis_scope_colors[(gint) vis->vs_data[x]]; | |
| 396 if (h > h2) { | |
| 397 y = h; | |
| 398 h = h2; | |
| 399 h2 = y; | |
| 400 } | |
| 401 ptr = rgb_data + (h * 304) + (x << 1); | |
| 402 for (y = h; y <= h2; y++, ptr += 304) { | |
| 403 *ptr = c; | |
| 404 *(ptr + 1) = c; | |
| 405 *(ptr + 152) = c; | |
| 406 *(ptr + 153) = c; | |
| 407 } | |
| 408 break; | |
| 409 } | |
| 410 } | |
| 411 } | |
| 1653 | 412 |
| 413 GDK_THREADS_ENTER(); | |
| 414 gdk_draw_indexed_image(vis->vs_window, vis->vs_widget.gc, | |
| 1938 | 415 vis->vs_widget.x << 1, |
| 416 vis->vs_widget.y << 1, | |
| 417 vis->vs_widget.width << 1, | |
| 418 vis->vs_widget.height << 1, | |
| 419 GDK_RGB_DITHER_NONE, (guchar *) rgb_data, | |
| 420 152, cmap); | |
| 1653 | 421 GDK_THREADS_LEAVE(); |
| 1938 | 422 } |
| 1653 | 423 |
| 424 gdk_rgb_cmap_free(cmap); | |
| 425 } | |
| 426 | |
| 427 void | |
| 428 vis_clear_data(Vis * vis) | |
| 429 { | |
| 430 gint i; | |
| 431 | |
| 432 if (!vis) | |
| 433 return; | |
| 434 | |
| 435 for (i = 0; i < 75; i++) { | |
| 436 vis->vs_data[i] = (cfg.vis_type == VIS_SCOPE) ? 6 : 0; | |
| 437 vis->vs_peak[i] = 0; | |
| 438 } | |
| 439 } | |
| 440 | |
| 441 void | |
| 1938 | 442 vis_set_doublesize(Vis * vis, gboolean doublesize) |
| 443 { | |
| 444 vis->vs_doublesize = doublesize; | |
| 445 } | |
| 446 | |
| 447 void | |
| 1653 | 448 vis_clear(Vis * vis) |
| 449 { | |
| 1938 | 450 if (!vis->vs_doublesize) |
| 451 gdk_window_clear_area(vis->vs_window, vis->vs_widget.x, | |
| 452 vis->vs_widget.y, vis->vs_widget.width, | |
| 453 vis->vs_widget.height); | |
| 454 else | |
| 455 gdk_window_clear_area(vis->vs_window, vis->vs_widget.x << 1, | |
| 456 vis->vs_widget.y << 1, | |
| 457 vis->vs_widget.width << 1, | |
| 458 vis->vs_widget.height << 1); | |
| 1653 | 459 } |
| 460 | |
| 461 void | |
| 462 vis_set_window(Vis * vis, GdkWindow * window) | |
| 463 { | |
| 464 vis->vs_window = window; | |
| 465 } | |
| 466 | |
| 467 Vis * | |
| 468 create_vis(GList ** wlist, | |
| 469 GdkPixmap * parent, | |
| 470 GdkWindow * window, | |
| 471 GdkGC * gc, | |
| 472 gint x, gint y, | |
| 1938 | 473 gint width, |
| 474 gboolean doublesize) | |
| 1653 | 475 { |
| 476 Vis *vis; | |
| 477 | |
| 478 vis = g_new0(Vis, 1); | |
| 479 | |
| 480 widget_init(&vis->vs_widget, parent, gc, x, y, width, 16, 1); | |
| 1938 | 481 |
| 482 vis->vs_doublesize = doublesize; | |
| 483 | |
| 1653 | 484 widget_list_add(wlist, WIDGET(vis)); |
| 485 | |
| 486 return vis; | |
| 487 } |
