Debian Codegraph @

plugins/actor/oinksie/gfx-analyzer.c

raw
1 /* Libvisual-plugins - Standard plugins for libvisual
2 *
3 * Copyright (C) 2002, 2003, 2004, 2005, 2006 Dennis Smit <[email protected]>
4 *
5 * Authors: Dennis Smit <[email protected]>
6 *
7 * $Id: gfx-analyzer.c,v 1.6 2006/01/22 13:25:26 synap Exp $
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23
24 #include "oinksie.h"
25 #include "common.h"
26 #include "screen.h"
27 #include "audio.h"
28 #include "gfx-misc.h"
29 #include "gfx-analyzer.h"
30
31 #define ANALYZER_BANDS 32
32
33 void _oink_gfx_analyzer_stereo (OinksiePrivate *priv, uint8_t *buf, int color, int y)
34 {
35 int adder = (priv->screen_width - ((priv->screen_halfwidth / ANALYZER_BANDS) * ANALYZER_BANDS * 2)) / 2;
36
37 int i;
38
39 int y1;
40 int x1;
41
42 int y2;
43 int x2;
44
45 int real_x = 0;
46 int real_x_add = (priv->screen_halfwidth / ANALYZER_BANDS);
47
48 y2 = y;
49 x2 = 0;
50
51 for (i = ANALYZER_BANDS; i >= 0; i--)
52 {
53 y1 = (-(priv->audio.freq[0][i] * priv->screen_height) * 2) + y;
54 x1 = real_x += real_x_add;
55
56 if (y1 < 0) y1 = 0;
57
58 _oink_gfx_line (priv, buf, color, x1 + adder, y1, x2 + adder, y2);
59
60 y2 = y1;
61 x2 = x1;
62 }
63
64 for (i = 1; i < ANALYZER_BANDS; i++)
65 {
66 y1 = (-(priv->audio.freq[1][i] * priv->screen_height) * 2) + y;
67 if (y1 == ANALYZER_BANDS - 1)
68 y1 = y;
69
70 x1 = real_x += real_x_add;
71
72 if (y1 < 0) y1 = 0;
73
74 _oink_gfx_line (priv, buf, color, x1 + adder, y1, x2 + adder, y2);
75
76 y2 = y1;
77 x2 = x1;
78 }
79 }
80