annotate audacious/visualization.c @ 1932:532bb9b2bef6 trunk

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