26 #define EQ_BANDS AUD_EQUALIZER_NBANDS
27 #define MAX_CHANNELS 10
37 static const float CF[
EQ_BANDS] = {31.25, 62.5, 125, 250, 500, 1000, 2000,
40 static pthread_mutex_t
mutex = PTHREAD_MUTEX_INITIALIZER;
50 static void bp2 (
float *
a,
float *
b,
float fc,
float q)
52 float th = 2 * M_PI * fc;
53 float C = (1 - tanf (th * q / 2)) / (1 + tanf (th * q / 2));
55 a[0] = (1 + C) * cosf (th);
65 pthread_mutex_lock (&
mutex);
73 while (
CF[
K - 1] > (
float)
rate / 2.2)
77 for (k = 0; k <
K; k ++)
81 memset (
wqv[0][0], 0,
sizeof wqv);
83 pthread_mutex_unlock (&
mutex);
90 adj[i] = preamp + values[i];
94 gv[c][i] = pow (10, adj[i] / 20) - 1;
101 pthread_mutex_lock (&
mutex);
105 pthread_mutex_unlock (&
mutex);
109 for (channel = 0; channel <
channels; channel ++)
111 float * g =
gv[channel];
112 float * end = data + samples;
115 for (f = data + channel; f < end; f +=
channels)
120 for (k = 0; k <
K; k ++)
123 float * wq =
wqv[channel][k];
125 float w = yt *
b[k][0] + wq[0] *
a[k][0] + wq[1] *
a[k][1];
128 yt += (w + wq[1] *
b[k][1]) * g[k];
140 pthread_mutex_unlock (&
mutex);
145 pthread_mutex_lock (&
mutex);
153 pthread_mutex_unlock (&
mutex);
174 g_return_if_fail (
string);
181 memset (values, 0,
sizeof (
double) *
EQ_BANDS);
189 g_return_if_fail (band >= 0 && band <
EQ_BANDS);
192 values[band] = value;
198 g_return_val_if_fail (band >= 0 && band <
EQ_BANDS, 0);