annotate Plugins/Input/musepack/equalizer.cpp @ 553:82346a6312c2 trunk

[svn] make WMA plugin strings translatable
author nenolod
date Wed, 01 Feb 2006 13:09:00 -0800
parents f13ab2d8e9cf
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
293
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
1 /*
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
2 * Thanks to Felipe Rivera for letting us use some code from his
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
3 * EQU-Plugin (http://equ.sourceforge.net/) for our Equalizer.
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
4 */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
5
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
6 #include <math.h>
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
7 #include <string.h>
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
8 #include <stdlib.h>
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
9 #include <glib.h>
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
10 #include "equalizer.h"
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
11
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
12 // Fixed Point Fractional bits
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
13 #define FP_FRBITS 28
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
14
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
15 // Conversions
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
16 #define EQ_REAL(x) ((gint)((x) * (1 << FP_FRBITS)))
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
17
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
18 /* Floating point */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
19 typedef struct {
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
20 float beta;
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
21 float alpha;
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
22 float gamma;
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
23 } sIIRCoefficients;
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
24
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
25 /* Coefficient history for the IIR filter */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
26 typedef struct {
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
27 float x[3]; /* x[n], x[n-1], x[n-2] */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
28 float y[3]; /* y[n], y[n-1], y[n-2] */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
29 } sXYData;
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
30
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
31 /* BETA, ALPHA, GAMMA */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
32 static sIIRCoefficients iir_cforiginal10[] = {
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
33 {(9.9421504945e-01), (2.8924752745e-03), (1.9941421835e+00)}, /* 60.0 Hz */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
34 {(9.8335039428e-01), (8.3248028618e-03), (1.9827686547e+00)}, /* 170.0 Hz */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
35 {(9.6958094144e-01), (1.5209529281e-02), (1.9676601546e+00)}, /* 310.0 Hz */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
36 {(9.4163923306e-01), (2.9180383468e-02), (1.9345490229e+00)}, /* 600.0 Hz */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
37 {(9.0450844499e-01), (4.7745777504e-02), (1.8852109613e+00)}, /* 1000.0 Hz */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
38 {(7.3940088234e-01), (1.3029955883e-01), (1.5829158753e+00)}, /* 3000.0 Hz */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
39 {(5.4697667908e-01), (2.2651166046e-01), (1.0153238114e+00)}, /* 6000.0 Hz */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
40 {(3.1023210589e-01), (3.4488394706e-01), (-1.8142472036e-01)}, /* 12000.0 Hz */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
41 {(2.6718639778e-01), (3.6640680111e-01), (-5.2117742267e-01)}, /* 14000.0 Hz */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
42 {(2.4201241845e-01), (3.7899379077e-01), (-8.0847117831e-01)}, /* 16000.0 Hz */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
43 };
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
44
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
45 /* History for two filters */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
46 static sXYData data_history[EQ_MAX_BANDS][EQ_CHANNELS];
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
47 static sXYData data_history2[EQ_MAX_BANDS][EQ_CHANNELS];
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
48
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
49 /* Coefficients */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
50 static sIIRCoefficients *iir_cf;
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
51
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
52 /* Gain for each band
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
53 * values should be between -0.2 and 1.0 */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
54 static float gain[10];
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
55 static float preamp;
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
56
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
57 int round_trick(float floatvalue_to_round);
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
58
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
59
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
60 static void
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
61 output_set_eq(gboolean active, gfloat pre, gfloat * bands)
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
62 {
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
63 int i;
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
64
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
65 preamp = 1.0 + 0.0932471 * pre + 0.00279033 * pre * pre;
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
66 for (i = 0; i < 10; ++i)
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
67 gain[i] = 0.03 * bands[i] + 0.000999999 * bands[i] * bands[i];
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
68 }
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
69
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
70 /* Init the filter */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
71 void
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
72 init_iir(int on, float preamp_ctrl, float *eq_ctrl)
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
73 {
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
74 iir_cf = iir_cforiginal10;
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
75
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
76 /* Zero the history arrays */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
77 memset(data_history, 0, sizeof(sXYData) * EQ_MAX_BANDS * EQ_CHANNELS);
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
78 memset(data_history2, 0, sizeof(sXYData) * EQ_MAX_BANDS * EQ_CHANNELS);
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
79
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
80 output_set_eq(on, preamp_ctrl, eq_ctrl);
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
81 }
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
82
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
83 int
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
84 iir(char *d, gint length)
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
85 {
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
86 gint16 *data = (gint16 *) d;
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
87
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
88 /* Indexes for the history arrays
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
89 * These have to be kept between calls to this function
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
90 * hence they are static */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
91 static gint i = 0, j = 2, k = 1;
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
92
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
93 gint index, band, channel;
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
94 gint tempgint, halflength;
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
95 float out[EQ_CHANNELS], pcm[EQ_CHANNELS];
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
96
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
97 /**
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
98 * IIR filter equation is
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
99 * y[n] = 2 * (alpha*(x[n]-x[n-2]) + gamma*y[n-1] - beta*y[n-2])
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
100 *
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
101 * NOTE: The 2 factor was introduced in the coefficients to save
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
102 * a multiplication
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
103 *
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
104 * This algorithm cascades two filters to get nice filtering
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
105 * at the expense of extra CPU cycles
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
106 */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
107 /* 16bit, 2 bytes per sample, so divide by two the length of
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
108 * the buffer (length is in bytes)
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
109 */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
110 halflength = (length >> 1);
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
111 for (index = 0; index < halflength; index += 2) {
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
112 /* For each channel */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
113 for (channel = 0; channel < EQ_CHANNELS; channel++) {
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
114 /* No need to scale when processing the PCM with the filter */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
115 pcm[channel] = data[index + channel];
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
116 /* Preamp gain */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
117 pcm[channel] *= preamp;
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
118
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
119 out[channel] = 0;
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
120 /* For each band */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
121 for (band = 0; band < 10; band++) {
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
122 /* Store Xi(n) */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
123 data_history[band][channel].x[i] = pcm[channel];
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
124 /* Calculate and store Yi(n) */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
125 data_history[band][channel].y[i] =
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
126 (iir_cf[band].alpha * (data_history[band][channel].x[i]
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
127 - data_history[band][channel].x[k])
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
128 + iir_cf[band].gamma * data_history[band][channel].y[j]
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
129 - iir_cf[band].beta * data_history[band][channel].y[k]
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
130 );
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
131 /*
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
132 * The multiplication by 2.0 was 'moved' into the coefficients to save
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
133 * CPU cycles here */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
134 /* Apply the gain */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
135 out[channel] += data_history[band][channel].y[i] * gain[band]; // * 2.0;
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
136 } /* For each band */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
137
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
138 if (false) {
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
139 /* Filter the sample again */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
140 for (band = 0; band < 10; band++) {
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
141 /* Store Xi(n) */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
142 data_history2[band][channel].x[i] = out[channel];
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
143 /* Calculate and store Yi(n) */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
144 data_history2[band][channel].y[i] =
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
145 (iir_cf[band].alpha *
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
146 (data_history2[band][channel].x[i]
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
147 - data_history2[band][channel].x[k])
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
148 +
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
149 iir_cf[band].gamma *
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
150 data_history2[band][channel].y[j]
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
151 -
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
152 iir_cf[band].beta * data_history2[band][channel].y[k]
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
153 );
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
154 /* Apply the gain */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
155 out[channel] +=
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
156 data_history2[band][channel].y[i] * gain[band];
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
157 } /* For each band */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
158 }
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
159
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
160 /* Volume stuff
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
161 Scale down original PCM sample and add it to the filters
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
162 output. This substitutes the multiplication by 0.25
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
163 */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
164
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
165 out[channel] += (data[index + channel] >> 2);
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
166
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
167 //printf("out[channel] = %f\n", out[channel]);
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
168 tempgint = (int) out[channel];
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
169
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
170 //printf("iir: old=%d new=%d\n", data[index+channel], tempgint);
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
171 /* Limit the output */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
172 if (tempgint < -32768)
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
173 data[index + channel] = -32768;
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
174 else if (tempgint > 32767)
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
175 data[index + channel] = 32767;
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
176 else
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
177 data[index + channel] = tempgint;
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
178 } /* For each channel */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
179
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
180 i++;
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
181 j++;
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
182 k++;
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
183
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
184 /* Wrap around the indexes */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
185 if (i == 3)
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
186 i = 0;
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
187 else if (j == 3)
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
188 j = 0;
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
189 else
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
190 k = 0;
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
191
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
192
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
193 } /* For each pair of samples */
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
194
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
195 return length;
9b191695629c [svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff changeset
196 }