annotate audacious/visualization.c @ 780:18b54ee82c24 trunk

[svn] - do not operate on a non-existant fd
author nenolod
date Thu, 02 Mar 2006 08:00:29 -0800
parents e4e897d20791
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 "visualization.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 <stdlib.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
26 #include <math.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
27 #include <string.h>
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
28
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
29 #include "fft.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
30 #include "input.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
31 #include "main.h"
538
e4e897d20791 [svn] remove libaudcore, we never did anything with it
nenolod
parents: 284
diff changeset
32 #include "playback.h"
0
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
33 #include "plugin.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
34 #include "prefswin.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
35 #include "svis.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
36 #include "vis.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
37 #include "widget.h"
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
38
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
39 VisPluginData vp_data = {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
40 NULL,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
41 NULL,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
42 FALSE
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
43 };
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
44
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
45 GList *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
46 get_vis_list(void)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
47 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
48 return vp_data.vis_list;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
49 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
50
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
51 GList *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
52 get_vis_enabled_list(void)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
53 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
54 return vp_data.enabled_list;
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 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
58 vis_disable_plugin(VisPlugin * vp)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
59 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
60 gint i = g_list_index(vp_data.vis_list, vp);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
61 enable_vis_plugin(i, FALSE);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
62 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
63
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
64 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
65 vis_about(gint i)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
66 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
67 GList *node = g_list_nth(vp_data.vis_list, i);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
68
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
69 if (node && node->data && VIS_PLUGIN(node->data)->about)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
70 VIS_PLUGIN(node->data)->about();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
71 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
72
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
73 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
74 vis_configure(gint i)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
75 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
76 GList *node = g_list_nth(vp_data.vis_list, i);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
77
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
78 if (node && node->data && VIS_PLUGIN(node->data)->configure)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
79 VIS_PLUGIN(node->data)->configure();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
80 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
81
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
82 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
83 vis_playback_start(void)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
84 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
85 GList *node;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
86 VisPlugin *vp;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
87
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
88 if (vp_data.playback_started)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
89 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
90
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
91 for (node = vp_data.enabled_list; node; node = g_list_next(node)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
92 vp = node->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
93 if (vp->playback_start)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
94 vp->playback_start();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
95 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
96 vp_data.playback_started = TRUE;
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 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
100 vis_playback_stop(void)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
101 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
102 GList *node = vp_data.enabled_list;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
103 VisPlugin *vp;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
104
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
105 if (!vp_data.playback_started)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
106 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
107
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
108 for (node = vp_data.enabled_list; node; node = g_list_next(node)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
109 vp = node->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
110 if (vp->playback_stop)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
111 vp->playback_stop();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
112 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
113 vp_data.playback_started = FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
114 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
115
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
116 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
117 enable_vis_plugin(gint i, gboolean enable)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
118 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
119 GList *node = g_list_nth(vp_data.vis_list, i);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
120 VisPlugin *vp;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
121
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
122 if (!node || !(node->data))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
123 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
124 vp = node->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
125
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
126 if (enable && !g_list_find(vp_data.enabled_list, vp)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
127 vp_data.enabled_list = g_list_append(vp_data.enabled_list, vp);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
128 if (vp->init)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
129 vp->init();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
130 if (bmp_playback_get_playing() && vp->playback_start)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
131 vp->playback_start();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
132 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
133 else if (!enable && g_list_find(vp_data.enabled_list, vp)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
134 vp_data.enabled_list = g_list_remove(vp_data.enabled_list, vp);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
135 if (bmp_playback_get_playing() && vp->playback_stop)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
136 vp->playback_stop();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
137 if (vp->cleanup)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
138 vp->cleanup();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
139 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
140 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
141
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
142 gboolean
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
143 vis_enabled(gint i)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
144 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
145 return (g_list_find
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
146 (vp_data.enabled_list,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
147 g_list_nth(vp_data.vis_list, i)->data) != NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
148 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
149
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
150 gchar *
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
151 vis_stringify_enabled_list(void)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
152 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
153 gchar *enalist = NULL, *tmp, *tmp2;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
154 GList *node = vp_data.enabled_list;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
155
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
156 if (g_list_length(node)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
157 enalist = g_path_get_basename(VIS_PLUGIN(node->data)->filename);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
158 for (node = g_list_next(node); node != NULL; node = g_list_next(node)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
159 tmp = enalist;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
160 tmp2 = g_path_get_basename(VIS_PLUGIN(node->data)->filename);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
161 enalist = g_strconcat(tmp, ",", tmp2, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
162 g_free(tmp);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
163 g_free(tmp2);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
164 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
165 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
166 return enalist;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
167 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
168
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
169 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
170 vis_enable_from_stringified_list(gchar * list)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
171 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
172 gchar **plugins, *base;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
173 GList *node;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
174 gint i;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
175 VisPlugin *vp;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
176
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
177 if (!list || !strcmp(list, ""))
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
178 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
179 plugins = g_strsplit(list, ",", 0);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
180 for (i = 0; plugins[i]; i++) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
181 for (node = vp_data.vis_list; node != NULL; node = g_list_next(node)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
182 base = g_path_get_basename(VIS_PLUGIN(node->data)->filename);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
183 if (!strcmp(plugins[i], base)) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
184 vp = node->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
185 vp_data.enabled_list =
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
186 g_list_append(vp_data.enabled_list, vp);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
187 if (vp->init)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
188 vp->init();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
189 if (bmp_playback_get_playing() && vp->playback_start)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
190 vp->playback_start();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
191 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
192 g_free(base);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
193 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
194 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
195 g_strfreev(plugins);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
196 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
197
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
198 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
199 calc_stereo_pcm(gint16 dest[2][512], gint16 src[2][512], gint nch)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
200 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
201 memcpy(dest[0], src[0], 512 * sizeof(gint16));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
202 if (nch == 1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
203 memcpy(dest[1], src[0], 512 * sizeof(gint16));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
204 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
205 memcpy(dest[1], src[1], 512 * sizeof(gint16));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
206 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
207
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
208 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
209 calc_mono_pcm(gint16 dest[2][512], gint16 src[2][512], gint nch)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
210 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
211 gint i;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
212 gint16 *d, *sl, *sr;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
213
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
214 if (nch == 1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
215 memcpy(dest[0], src[0], 512 * sizeof(gint16));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
216 else {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
217 d = dest[0];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
218 sl = src[0];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
219 sr = src[1];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
220 for (i = 0; i < 512; i++) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
221 *(d++) = (*(sl++) + *(sr++)) >> 1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
222 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
223 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
224 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
225
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
226 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
227 calc_freq(gint16 * dest, gint16 * src)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
228 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
229 static fft_state *state = NULL;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
230 gfloat tmp_out[257];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
231 gint i;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
232
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
233 if (!state)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
234 state = fft_init();
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
235
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
236 fft_perform(src, tmp_out, state);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
237
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
238 for (i = 0; i < 256; i++)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
239 dest[i] = ((gint) sqrt(tmp_out[i + 1])) >> 8;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
240 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
241
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
242 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
243 calc_mono_freq(gint16 dest[2][256], gint16 src[2][512], gint nch)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
244 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
245 gint i;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
246 gint16 *d, *sl, *sr, tmp[512];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
247
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
248 if (nch == 1)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
249 calc_freq(dest[0], src[0]);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
250 else {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
251 d = tmp;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
252 sl = src[0];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
253 sr = src[1];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
254 for (i = 0; i < 512; i++) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
255 *(d++) = (*(sl++) + *(sr++)) >> 1;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
256 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
257 calc_freq(dest[0], tmp);
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 static void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
262 calc_stereo_freq(gint16 dest[2][256], gint16 src[2][512], gint nch)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
263 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
264 calc_freq(dest[0], src[0]);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
265
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
266 if (nch == 2)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
267 calc_freq(dest[1], src[1]);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
268 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
269 memcpy(dest[1], dest[0], 256 * sizeof(gint16));
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
270 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
271
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
272 void
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
273 vis_send_data(gint16 pcm_data[2][512], gint nch, gint length)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
274 {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
275 GList *node = vp_data.enabled_list;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
276 VisPlugin *vp;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
277 gint16 mono_freq[2][256], stereo_freq[2][256];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
278 gboolean mono_freq_calced = FALSE, stereo_freq_calced = FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
279 gint16 mono_pcm[2][512], stereo_pcm[2][512];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
280 gboolean mono_pcm_calced = FALSE, stereo_pcm_calced = FALSE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
281 guint8 intern_vis_data[512];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
282 gint i;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
283
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
284 if (!pcm_data || nch < 1) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
285 if (cfg.vis_type != VIS_OFF) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
286 if (cfg.player_shaded && cfg.player_visible)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
287 svis_timeout_func(mainwin_svis, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
288 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
289 vis_timeout_func(active_vis, NULL);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
290 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
291 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
292 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
293
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
294 while (node) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
295 vp = node->data;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
296 if (vp->num_pcm_chs_wanted > 0 && vp->render_pcm) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
297 if (vp->num_pcm_chs_wanted == 1) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
298 if (!mono_pcm_calced) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
299 calc_mono_pcm(mono_pcm, pcm_data, nch);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
300 mono_pcm_calced = TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
301 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
302 vp->render_pcm(mono_pcm);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
303 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
304 else {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
305 if (!stereo_pcm_calced) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
306 calc_stereo_pcm(stereo_pcm, pcm_data, nch);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
307 stereo_pcm_calced = TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
308 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
309 vp->render_pcm(stereo_pcm);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
310 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
311 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
312 if (vp->num_freq_chs_wanted > 0 && vp->render_freq) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
313 if (vp->num_freq_chs_wanted == 1) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
314 if (!mono_freq_calced) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
315 calc_mono_freq(mono_freq, pcm_data, nch);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
316 mono_freq_calced = TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
317 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
318 vp->render_freq(mono_freq);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
319 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
320 else {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
321 if (!stereo_freq_calced) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
322 calc_stereo_freq(stereo_freq, pcm_data, nch);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
323 stereo_freq_calced = TRUE;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
324 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
325 vp->render_freq(stereo_freq);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
326 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
327 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
328 node = g_list_next(node);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
329 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
330
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
331 if (cfg.vis_type == VIS_OFF)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
332 return;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
333
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
334 if (cfg.vis_type == VIS_ANALYZER) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
335 if (cfg.player_shaded && cfg.player_visible) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
336 /* VU */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
337 gint vu, val;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
338
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
339 if (!stereo_pcm_calced)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
340 calc_stereo_pcm(stereo_pcm, pcm_data, nch);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
341 vu = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
342 for (i = 0; i < 512; i++) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
343 val = abs(stereo_pcm[0][i]);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
344 if (val > vu)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
345 vu = val;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
346 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
347 intern_vis_data[0] = (vu * 37) >> 15;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
348 if (intern_vis_data[0] > 37)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
349 intern_vis_data[0] = 37;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
350 if (nch == 2) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
351 vu = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
352 for (i = 0; i < 512; i++) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
353 val = abs(stereo_pcm[1][i]);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
354 if (val > vu)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
355 vu = val;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
356 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
357 intern_vis_data[1] = (vu * 37) >> 15;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
358 if (intern_vis_data[1] > 37)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
359 intern_vis_data[1] = 37;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
360 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
361 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
362 intern_vis_data[1] = intern_vis_data[0];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
363 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
364 else {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
365 /* Spectrum analyzer */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
366 /* 76 values */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
367 const gint long_xscale[] =
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
368 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
369 17, 18,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
370 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
371 34,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
372 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
373 50, 51,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
374 52, 53, 54, 55, 56, 57, 58, 61, 66, 71, 76, 81, 87, 93,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
375 100, 107,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
376 114, 122, 131, 140, 150, 161, 172, 184, 255
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
377 };
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
378 /* 20 values */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
379 const int short_xscale[] =
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
380 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 11, 15, 20, 27,
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
381 36, 47, 62, 82, 107, 141, 184, 255
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
382 };
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
383 const double y_scale = 3.60673760222; /* 20.0 / log(256) */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
384 const int *xscale;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
385 gint j, y, max;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
386
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
387 if (!mono_freq_calced)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
388 calc_mono_freq(mono_freq, pcm_data, nch);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
389
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
390 memset(intern_vis_data, 0, 75);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
391
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
392 if (cfg.analyzer_type == ANALYZER_BARS) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
393 max = 19;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
394 xscale = short_xscale;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
395 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
396 else {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
397 max = 75;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
398 xscale = long_xscale;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
399 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
400
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
401 for (i = 0; i < max; i++) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
402 for (j = xscale[i], y = 0; j < xscale[i + 1]; j++) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
403 if (mono_freq[0][j] > y)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
404 y = mono_freq[0][j];
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
405 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
406 y >>= 7;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
407 if (y != 0) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
408 intern_vis_data[i] = log(y) * y_scale;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
409 if (intern_vis_data[i] > 15)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
410 intern_vis_data[i] = 15;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
411 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
412 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
413 intern_vis_data[i] = 0;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
414 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
415 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
416 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
417 else { /* (cfg.vis_type == VIS_SCOPE) */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
418
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
419 /* Osciloscope */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
420 gint pos, step;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
421
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
422 if (!mono_pcm_calced)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
423 calc_mono_pcm(mono_pcm, pcm_data, nch);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
424
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
425 step = (length << 8) / 74;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
426 for (i = 0, pos = 0; i < 75; i++, pos += step) {
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
427 intern_vis_data[i] = ((mono_pcm[0][pos >> 8]) >> 11) + 6;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
428 if (intern_vis_data[i] > 12)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
429 intern_vis_data[i] = 12;
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
430 /* Do not see the point of that? (comparison always false) -larne.
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
431 if (intern_vis_data[i] < 0)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
432 intern_vis_data[i] = 0; */
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
433 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
434 }
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
435 if (cfg.player_shaded && cfg.player_visible)
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
436 svis_timeout_func(mainwin_svis, intern_vis_data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
437 else
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
438 vis_timeout_func(active_vis, intern_vis_data);
cb178e5ad177 [svn] Import audacious source.
nenolod
parents:
diff changeset
439 }