Mercurial > audlegacy
annotate src/audacious/widgets/vis.c @ 2456:63115d6e8ba8 trunk
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
| author | marvin |
|---|---|
| date | Wed, 31 Jan 2007 16:47:18 -0800 |
| parents | d88558b0de0a |
| children |
| rev | line source |
|---|---|
| 2313 | 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" | |
| 2328 | 31 #include "playback.h" |
| 2313 | 32 |
| 33 static const gfloat vis_afalloff_speeds[] = { 0.34, 0.5, 1.0, 1.3, 1.6 }; | |
| 34 static const gfloat vis_pfalloff_speeds[] = { 1.2, 1.3, 1.4, 1.5, 1.6 }; | |
| 35 static const gint vis_redraw_delays[] = { 1, 2, 4, 8 }; | |
| 36 static const guint8 vis_scope_colors[] = | |
| 37 { 21, 21, 20, 20, 19, 19, 18, 19, 19, 20, 20, 21, 21 }; | |
| 38 static guchar voiceprint_data[76*16]; | |
| 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; | |
| 2328 | 46 gint i; |
| 2313 | 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 if (cfg.vis_type == VIS_ANALYZER) { | |
| 58 if (micros > 14000) | |
| 59 falloff = TRUE; | |
| 60 if (data || falloff) { | |
| 61 for (i = 0; i < 75; i++) { | |
| 62 if (data && data[i] > vis->vs_data[i]) { | |
| 63 vis->vs_data[i] = data[i]; | |
| 64 if (vis->vs_data[i] > vis->vs_peak[i]) { | |
| 65 vis->vs_peak[i] = vis->vs_data[i]; | |
| 66 vis->vs_peak_speed[i] = 0.01; | |
| 67 | |
| 68 } | |
| 69 else if (vis->vs_peak[i] > 0.0) { | |
| 70 vis->vs_peak[i] -= vis->vs_peak_speed[i]; | |
| 71 vis->vs_peak_speed[i] *= | |
| 72 vis_pfalloff_speeds[cfg.peaks_falloff]; | |
| 73 if (vis->vs_peak[i] < vis->vs_data[i]) | |
| 74 vis->vs_peak[i] = vis->vs_data[i]; | |
| 75 if (vis->vs_peak[i] < 0.0) | |
| 76 vis->vs_peak[i] = 0.0; | |
| 77 } | |
| 78 } | |
| 79 else if (falloff) { | |
| 80 if (vis->vs_data[i] > 0.0) { | |
| 81 vis->vs_data[i] -= | |
| 82 vis_afalloff_speeds[cfg.analyzer_falloff]; | |
| 83 if (vis->vs_data[i] < 0.0) | |
| 84 vis->vs_data[i] = 0.0; | |
| 85 } | |
| 86 if (vis->vs_peak[i] > 0.0) { | |
| 87 vis->vs_peak[i] -= vis->vs_peak_speed[i]; | |
| 88 vis->vs_peak_speed[i] *= | |
| 89 vis_pfalloff_speeds[cfg.peaks_falloff]; | |
| 90 if (vis->vs_peak[i] < vis->vs_data[i]) | |
| 91 vis->vs_peak[i] = vis->vs_data[i]; | |
| 92 if (vis->vs_peak[i] < 0.0) | |
| 93 vis->vs_peak[i] = 0.0; | |
| 94 } | |
| 95 } | |
| 96 } | |
| 97 } | |
| 98 } | |
| 99 else if (cfg.vis_type == VIS_VOICEPRINT && data){ | |
| 100 for(i = 0; i < 16; i++) | |
| 101 { | |
| 102 vis->vs_data[i] = data[15 - i]; | |
| 103 } | |
| 104 } | |
| 105 else if (data) { | |
| 106 for (i = 0; i < 75; i++) | |
| 107 vis->vs_data[i] = data[i]; | |
| 108 } | |
| 109 | |
| 110 if (micros > 14000) { | |
| 111 if (!vis->vs_refresh_delay) { | |
| 112 vis_draw((Widget *) vis); | |
| 113 vis->vs_refresh_delay = vis_redraw_delays[cfg.vis_refresh]; | |
| 114 | |
| 115 } | |
| 116 vis->vs_refresh_delay--; | |
| 117 } | |
| 118 } | |
| 119 void | |
| 120 vis_draw(Widget * w) | |
| 121 { | |
| 122 Vis *vis = (Vis *) w; | |
| 123 gint x, y, n, h = 0, h2; | |
|
2456
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
124 gfloat delta; |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
125 guchar skin_col[2][3]; |
| 2313 | 126 guchar vis_color[24][3]; |
|
2456
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
127 guchar vis_voice_color[256][3], voice_c[3]; |
| 2313 | 128 guchar rgb_data[76 * 16 * 3 * 2 * 2], *ptr, c; |
| 129 guint32 colors[24]; | |
|
2456
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
130 GdkColor *fgc, *bgc; |
| 2313 | 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 | |
| 143 if (!vis->vs_doublesize) { | |
|
2456
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
144 if(cfg.vis_type == VIS_VOICEPRINT /*&& cfg.voiceprint_mode != VOICEPRINT_NORMAL*/){ |
| 2313 | 145 memset(rgb_data, 0, 76 * 16 * 3); |
| 146 } | |
| 147 else{ | |
| 148 memset(rgb_data, 0, 76 * 16); | |
| 149 for (y = 1; y < 16; y += 2) { | |
| 150 ptr = rgb_data + (y * 76); | |
| 151 for (x = 0; x < 76; x += 2, ptr += 2) | |
| 152 *ptr = 1; | |
| 153 } | |
| 154 } | |
| 155 } | |
| 156 else{ | |
|
2456
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
157 if(cfg.vis_type == VIS_VOICEPRINT /*&& cfg.voiceprint_mode != VOICEPRINT_NORMAL*/){ |
| 2313 | 158 memset(rgb_data, 0, 3 * 4 * 16 * 76); |
| 159 } | |
| 160 else{ | |
| 161 memset(rgb_data, 0, 152 * 32); | |
| 162 for (y = 1; y < 16; y += 2) { | |
| 163 ptr = rgb_data + (y * 304); | |
| 164 for (x = 0; x < 76; x += 2, ptr += 4) { | |
| 165 *ptr = 1; | |
| 166 *(ptr + 1) = 1; | |
| 167 *(ptr + 152) = 1; | |
| 168 *(ptr + 153) = 1; | |
| 169 } | |
| 170 } | |
| 171 } | |
| 172 } | |
| 173 if (cfg.vis_type == VIS_ANALYZER) { | |
| 174 for (x = 0; x < 75; x++) { | |
| 175 if (cfg.analyzer_type == ANALYZER_BARS && (x % 4) == 0) | |
| 176 h = vis->vs_data[x >> 2]; | |
| 177 else if (cfg.analyzer_type == ANALYZER_LINES) | |
| 178 h = vis->vs_data[x]; | |
| 179 if (h && (cfg.analyzer_type == ANALYZER_LINES || | |
| 180 (x % 4) != 3)) { | |
| 181 if (!vis->vs_doublesize) { | |
| 182 ptr = rgb_data + ((16 - h) * 76) + x; | |
| 183 switch (cfg.analyzer_mode) { | |
| 184 case ANALYZER_NORMAL: | |
| 185 for (y = 0; y < h; y++, ptr += 76) | |
| 186 *ptr = 18 - h + y; | |
| 187 break; | |
| 188 case ANALYZER_FIRE: | |
| 189 for (y = 0; y < h; y++, ptr += 76) | |
| 190 *ptr = y + 2; | |
| 191 break; | |
| 192 case ANALYZER_VLINES: | |
| 193 for (y = 0; y < h; y++, ptr += 76) | |
| 194 *ptr = 18 - h; | |
| 195 break; | |
| 196 } | |
| 197 } | |
| 198 else{ | |
| 199 ptr = rgb_data + ((16 - h) * 304) + (x << 1); | |
| 200 switch (cfg.analyzer_mode) { | |
| 201 case ANALYZER_NORMAL: | |
| 202 for (y = 0; y < h; y++, ptr += 304) { | |
| 203 *ptr = 18 - h + y; | |
| 204 *(ptr + 1) = 18 - h + y; | |
| 205 *(ptr + 152) = 18 - h + y; | |
| 206 *(ptr + 153) = 18 - h + y; | |
| 207 } | |
| 208 break; | |
| 209 case ANALYZER_FIRE: | |
| 210 for (y = 0; y < h; y++, ptr += 304) { | |
| 211 *ptr = y + 2; | |
| 212 *(ptr + 1) = y + 2; | |
| 213 *(ptr + 152) = y + 2; | |
| 214 *(ptr + 153) = y + 2; | |
| 215 } | |
| 216 break; | |
| 217 case ANALYZER_VLINES: | |
| 218 for (y = 0; y < h; y++, ptr += 304) { | |
| 219 *ptr = 18 - h; | |
| 220 *(ptr + 1) = 18 - h; | |
| 221 *(ptr + 152) = 18 - h; | |
| 222 *(ptr + 153) = 18 - h; | |
| 223 } | |
| 224 | |
| 225 break; | |
| 226 } | |
| 227 } | |
| 228 } | |
| 229 } | |
| 230 if (cfg.analyzer_peaks) { | |
| 231 for (x = 0; x < 75; x++) { | |
| 232 if (cfg.analyzer_type == ANALYZER_BARS && (x % 4) == 0) | |
| 233 h = vis->vs_peak[x >> 2]; | |
| 234 else if (cfg.analyzer_type == ANALYZER_LINES) | |
| 235 h = vis->vs_peak[x]; | |
| 236 if (h && (cfg.analyzer_type == ANALYZER_LINES || (x % 4) != 3)){ | |
| 237 | |
| 238 if (!vis->vs_doublesize) { | |
| 239 rgb_data[(16 - h) * 76 + x] = 23; | |
| 240 } | |
| 241 else{ | |
| 242 ptr = rgb_data + (16 - h) * 304 + (x << 1); | |
| 243 *ptr = 23; | |
| 244 *(ptr + 1) = 23; | |
| 245 *(ptr + 152) = 23; | |
| 246 *(ptr + 153) = 23; | |
| 247 } | |
| 248 } | |
| 249 } | |
| 250 } | |
| 251 } | |
| 252 else if (cfg.vis_type == VIS_VOICEPRINT) { | |
| 253 if(!playback_get_paused() && playback_get_playing()){/*Don't scroll when it's paused or stopped*/ | |
| 254 for (y = 0; y < 16; y ++) | |
| 255 for (x = 75; x > 0; x--) | |
| 256 voiceprint_data[x + y * 76] = voiceprint_data[x-1+y*76]; | |
| 257 for(y=0;y<16;y++) | |
| 258 voiceprint_data[y * 76] = vis->vs_data[y]; | |
| 259 } | |
| 260 if(playback_get_playing()){ /*Only draw the data if we're playing*/ | |
|
2456
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
261 if(cfg.voiceprint_mode == VOICEPRINT_NORMAL){ |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
262 /* Create color gradient from the skin's background- and foreground color*/ |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
263 fgc = skin_get_color(bmp_active_skin, SKIN_TEXTFG); |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
264 bgc = skin_get_color(bmp_active_skin, SKIN_TEXTBG); |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
265 skin_col[0][0] = fgc->red >> 8; |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
266 skin_col[0][1] = fgc->green >> 8; |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
267 skin_col[0][2] = fgc->blue >> 8; |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
268 skin_col[1][0] = bgc->red >> 8; |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
269 skin_col[1][1] = bgc->green >> 8; |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
270 skin_col[1][2] = bgc->blue >> 8; |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
271 for(n=0;n<3;n++){ |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
272 for(x=0;x<256;x++){ |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
273 if(skin_col[0][n] > skin_col[1][n]){ |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
274 delta = (gfloat)(skin_col[0][n] - skin_col[1][n]) / 256.0; |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
275 vis_voice_color[x][n] = skin_col[1][n] + (gfloat)(delta * x); |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
276 } |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
277 else if(skin_col[0][n] == skin_col[1][n]){ |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
278 vis_voice_color[x][n] = skin_col[0][n]; |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
279 } |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
280 else{ |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
281 delta = (gfloat)(skin_col[1][n] - skin_col[0][n]) / 256.0; |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
282 vis_voice_color[x][n] = skin_col[1][n] - (gfloat)(delta * x); |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
283 } |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
284 } |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
285 } |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
286 } |
| 2313 | 287 for (y = 0; y < 16; y ++){ |
| 288 for (x = 0; x < 76; x++){ | |
| 289 guint8 d = voiceprint_data[x + y*76]; | |
|
2456
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
290 |
| 2313 | 291 if(cfg.voiceprint_mode == VOICEPRINT_NORMAL){ |
|
2456
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
292 voice_c[0] = vis_voice_color[d][0]; |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
293 voice_c[1] = vis_voice_color[d][1]; |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
294 voice_c[2] = vis_voice_color[d][2]; |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
295 } |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
296 else if(cfg.voiceprint_mode == VOICEPRINT_FIRE){ |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
297 voice_c[0] = d < 64 ? (d * 2) : 255; |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
298 voice_c[1] = d < 64 ? 0 : (d < 128 ? (d-64) * 2 : 255); |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
299 voice_c[2] = d < 128 ? 0 : (d-128) * 2; |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
300 /* Test for black->blue->green->red. Isn't pretty, though... |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
301 voice_c[0] = d > 192 ? (d - 192) << 2 : 0; |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
302 voice_c[1] = d > 64 ? (d < 128 ? (d - 64) << 2 : (d < 192 ? (192 - d) << 2 : 0)) : 0; |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
303 voice_c[2] = d < 64 ? d << 2 : (d < 128 ? (128 - d) << 2 : 0); |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
304 */ |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
305 } |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
306 else if(cfg.voiceprint_mode == VOICEPRINT_ICE){ |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
307 voice_c[0] = d; |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
308 voice_c[1] = d < 128 ? d * 2 : 255; |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
309 voice_c[2] = d < 64 ? d * 4 : 255; |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
310 } |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
311 if(!vis->vs_doublesize){ |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
312 for(n=0;n<3;n++) |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
313 rgb_data[x * 3 + y * 76*3+n] = voice_c[n]; |
| 2313 | 314 } |
| 315 else{ | |
|
2456
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
316 ptr = rgb_data + x * 3 * 2 + y * 2 * 76 * 3 * 2; |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
317 for(n=0;n<3;n++) |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
318 { |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
319 *(ptr + n) = voice_c[n]; |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
320 *(ptr + n + 3) = voice_c[n]; |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
321 *(ptr + n + 76 * 2 * 3) = voice_c[n]; |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
322 *(ptr + n + 3 + 76 * 2 * 3) = voice_c[n]; |
|
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
323 } |
| 2313 | 324 } |
| 325 } | |
| 326 } | |
| 327 } | |
| 328 } | |
|
2456
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
329 if (cfg.vis_type == VIS_SCOPE) { |
| 2313 | 330 for (x = 0; x < 75; x++) { |
| 331 switch (cfg.scope_mode) { | |
| 332 case SCOPE_DOT: | |
| 333 h = vis->vs_data[x]; | |
| 334 if (!vis->vs_doublesize) { | |
| 335 ptr = rgb_data + ((14 - h) * 76) + x; | |
| 336 *ptr = vis_scope_colors[h + 1]; | |
| 337 }else{ | |
| 338 ptr = rgb_data + ((14 - h) * 304) + (x << 1); | |
| 339 *ptr = vis_scope_colors[h + 1]; | |
| 340 *(ptr + 1) = vis_scope_colors[h + 1]; | |
| 341 *(ptr + 152) = vis_scope_colors[h + 1]; | |
| 342 *(ptr + 153) = vis_scope_colors[h + 1]; | |
| 343 } | |
| 344 break; | |
| 345 case SCOPE_LINE: | |
| 346 if (x != 74) { | |
| 347 h = 14 - vis->vs_data[x]; | |
| 348 h2 = 14 - vis->vs_data[x + 1]; | |
| 349 if (h > h2) { | |
| 350 y = h; | |
| 351 h = h2; | |
| 352 h2 = y; | |
| 353 } | |
| 354 if (!vis->vs_doublesize) { | |
| 355 ptr = rgb_data + (h * 76) + x; | |
| 356 for (y = h; y <= h2; y++, ptr += 76) | |
| 357 *ptr = vis_scope_colors[y - 2]; | |
| 358 } | |
| 359 else{ | |
| 360 ptr = rgb_data + (h * 304) + (x << 1); | |
| 361 for (y = h; y <= h2; y++, ptr += 304) { | |
| 362 *ptr = vis_scope_colors[y - 2]; | |
| 363 *(ptr + 1) = vis_scope_colors[y - 2]; | |
| 364 *(ptr + 152) = vis_scope_colors[y - 2]; | |
| 365 *(ptr + 153) = vis_scope_colors[y - 2]; | |
| 366 } | |
| 367 } | |
| 368 } | |
| 369 else { | |
| 370 h = 14 - vis->vs_data[x]; | |
| 371 if (!vis->vs_doublesize) { | |
| 372 ptr = rgb_data + (h * 76) + x; | |
| 373 *ptr = vis_scope_colors[h + 1]; | |
| 374 }else{ | |
| 375 ptr = rgb_data + (h * 304) + (x << 1); | |
| 376 *ptr = vis_scope_colors[h + 1]; | |
| 377 *(ptr + 1) = vis_scope_colors[h + 1]; | |
| 378 *(ptr + 152) = vis_scope_colors[h + 1]; | |
| 379 *(ptr + 153) = vis_scope_colors[h + 1]; | |
| 380 } | |
| 381 } | |
| 382 break; | |
| 383 case SCOPE_SOLID: | |
| 384 h = 14 - vis->vs_data[x]; | |
| 385 h2 = 8; | |
| 386 c = vis_scope_colors[(gint) vis->vs_data[x]]; | |
| 387 if (h > h2) { | |
| 388 y = h; | |
| 389 h = h2; | |
| 390 h2 = y; | |
| 391 } | |
| 392 if (!vis->vs_doublesize) { | |
| 393 ptr = rgb_data + (h * 76) + x; | |
| 394 for (y = h; y <= h2; y++, ptr += 76) | |
| 395 *ptr = c; | |
| 396 }else{ | |
| 397 ptr = rgb_data + (h * 304) + (x << 1); | |
| 398 for (y = h; y <= h2; y++, ptr += 304) { | |
| 399 *ptr = c; | |
| 400 *(ptr + 1) = c; | |
| 401 *(ptr + 152) = c; | |
| 402 *(ptr + 153) = c; | |
| 403 } | |
| 404 } | |
| 405 break; | |
| 406 } | |
| 407 } | |
| 408 } | |
| 409 | |
| 410 | |
| 411 | |
| 412 if (!vis->vs_doublesize) { | |
| 413 GDK_THREADS_ENTER(); | |
|
2456
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
414 if (cfg.vis_type == VIS_VOICEPRINT /*&& cfg.voiceprint_mode != VOICEPRINT_NORMAL*/){ |
| 2313 | 415 gdk_draw_rgb_image(vis->vs_window, vis->vs_widget.gc, |
| 416 vis->vs_widget.x, vis->vs_widget.y, | |
| 417 vis->vs_widget.width, vis->vs_widget.height, | |
| 418 GDK_RGB_DITHER_NORMAL, (guchar *) rgb_data, | |
| 419 76 * 3); | |
| 420 } | |
| 421 else{ | |
| 422 gdk_draw_indexed_image(vis->vs_window, vis->vs_widget.gc, | |
| 423 vis->vs_widget.x, vis->vs_widget.y, | |
| 424 vis->vs_widget.width, vis->vs_widget.height, | |
| 425 GDK_RGB_DITHER_NORMAL, (guchar *) rgb_data, | |
| 426 76, cmap); | |
| 427 } | |
| 428 GDK_THREADS_LEAVE(); | |
| 429 } | |
| 430 else { | |
| 431 GDK_THREADS_ENTER(); | |
|
2456
63115d6e8ba8
[svn] - Make the voiceprint use the skin's foreground and background color for the gradient in 'normal' mode
marvin
parents:
2328
diff
changeset
|
432 if (cfg.vis_type == VIS_VOICEPRINT /*&& cfg.voiceprint_mode != VOICEPRINT_NORMAL*/){ |
| 2313 | 433 gdk_draw_rgb_image(vis->vs_window, vis->vs_widget.gc, |
| 434 vis->vs_widget.x << 1, | |
| 435 vis->vs_widget.y << 1, | |
| 436 vis->vs_widget.width << 1, | |
| 437 vis->vs_widget.height << 1, | |
| 438 GDK_RGB_DITHER_NONE, (guchar *) rgb_data, | |
| 439 76 * 2 * 3); | |
| 440 } | |
| 441 else{ | |
| 442 gdk_draw_indexed_image(vis->vs_window, vis->vs_widget.gc, | |
| 443 vis->vs_widget.x << 1, | |
| 444 vis->vs_widget.y << 1, | |
| 445 vis->vs_widget.width << 1, | |
| 446 vis->vs_widget.height << 1, | |
| 447 GDK_RGB_DITHER_NONE, (guchar *) rgb_data, | |
| 448 76 * 2 , cmap); | |
| 449 } | |
| 450 GDK_THREADS_LEAVE(); | |
| 451 } | |
| 452 gdk_rgb_cmap_free(cmap); | |
| 453 } | |
| 454 | |
| 455 | |
| 456 | |
| 457 void | |
| 458 vis_clear_data(Vis * vis) | |
| 459 { | |
| 460 gint i; | |
| 461 | |
| 462 if (!vis) | |
| 463 return; | |
| 464 memset(voiceprint_data, 0, 16*76); | |
| 465 for (i = 0; i < 75; i++) { | |
| 466 vis->vs_data[i] = (cfg.vis_type == VIS_SCOPE) ? 6 : 0; | |
| 467 vis->vs_peak[i] = 0; | |
| 468 } | |
| 469 } | |
| 470 | |
| 471 void | |
| 472 vis_set_doublesize(Vis * vis, gboolean doublesize) | |
| 473 { | |
| 474 vis->vs_doublesize = doublesize; | |
| 475 } | |
| 476 | |
| 477 void | |
| 478 vis_clear(Vis * vis) | |
| 479 { | |
| 480 if (!vis->vs_doublesize) | |
| 481 gdk_window_clear_area(vis->vs_window, vis->vs_widget.x, | |
| 482 vis->vs_widget.y, vis->vs_widget.width, | |
| 483 vis->vs_widget.height); | |
| 484 else | |
| 485 gdk_window_clear_area(vis->vs_window, vis->vs_widget.x << 1, | |
| 486 vis->vs_widget.y << 1, | |
| 487 vis->vs_widget.width << 1, | |
| 488 vis->vs_widget.height << 1); | |
| 489 } | |
| 490 | |
| 491 void | |
| 492 vis_set_window(Vis * vis, GdkWindow * window) | |
| 493 { | |
| 494 vis->vs_window = window; | |
| 495 } | |
| 496 | |
| 497 void vis_draw_pixel(Vis * vis, guchar* texture, gint x, gint y, guint8 colour){ | |
| 498 if(vis->vs_doublesize){ | |
| 499 texture[y * 76 + x] = colour; | |
| 500 texture[y * 76 + x + 1] = colour; | |
| 501 texture[y * 76 * 4 + x] = colour; | |
| 502 texture[y * 76 * 4 + x + 1] = colour; | |
| 503 } | |
| 504 else{ | |
| 505 texture[y * 76 + x] = colour; | |
| 506 } | |
| 507 } | |
| 508 | |
| 509 | |
| 510 Vis * | |
| 511 create_vis(GList ** wlist, | |
| 512 GdkPixmap * parent, | |
| 513 GdkWindow * window, | |
| 514 GdkGC * gc, | |
| 515 gint x, gint y, | |
| 516 gint width, | |
| 517 gboolean doublesize) | |
| 518 { | |
| 519 Vis *vis; | |
| 520 | |
| 521 vis = g_new0(Vis, 1); | |
| 522 memset(voiceprint_data, 0, 16*76); | |
| 523 widget_init(&vis->vs_widget, parent, gc, x, y, width, 16, 1); | |
| 524 | |
| 525 vis->vs_doublesize = doublesize; | |
| 526 | |
| 527 widget_list_add(wlist, WIDGET(vis)); | |
| 528 | |
| 529 return vis; | |
| 530 } |
