38 #define EQ_BANDS AUD_EQUALIZER_NBANDS
39 #define MAX_CHANNELS 10
49 static const float CF[
EQ_BANDS] = {31.25, 62.5, 125, 250, 500, 1000, 2000,
52 static pthread_mutex_t
mutex = PTHREAD_MUTEX_INITIALIZER;
62 static void bp2 (
float *
a,
float *
b,
float fc,
float q)
64 float th = 2 * M_PI * fc;
65 float C = (1 - tanf (th * q / 2)) / (1 + tanf (th * q / 2));
67 a[0] = (1 + C) * cosf (th);
77 pthread_mutex_lock (&
mutex);
85 while (
CF[
K - 1] > (
float)
rate / 2.2)
89 for (k = 0; k <
K; k ++)
93 memset (
wqv[0][0], 0,
sizeof wqv);
95 pthread_mutex_unlock (&
mutex);
102 adj[i] = preamp + values[i];
106 gv[c][i] = pow (10, adj[i] / 20) - 1;
113 pthread_mutex_lock (&
mutex);
117 pthread_mutex_unlock (&
mutex);
121 for (channel = 0; channel <
channels; channel ++)
123 float *g =
gv[channel];
124 float *end = data + samples;
127 for (f = data + channel; f < end; f +=
channels)
132 for (k = 0; k <
K; k ++)
135 float *wq =
wqv[channel][k];
137 float w = yt *
b[k][0] + wq[0] *
a[k][0] + wq[1] *
a[k][1];
140 yt += (w + wq[1] *
b[k][1]) * g[k];
152 pthread_mutex_unlock (&
mutex);
157 pthread_mutex_lock (&
mutex);
165 pthread_mutex_unlock (&
mutex);
186 g_return_if_fail (
string);
193 memset (values, 0,
sizeof (
double) *
EQ_BANDS);
201 g_return_if_fail (band >= 0 && band <
EQ_BANDS);
204 values[band] = value;
210 g_return_val_if_fail (band >= 0 && band <
EQ_BANDS, 0);
static void eq_set_bands_real(double preamp, double *values)
static float gv[MAX_CHANNELS][EQ_BANDS]
static pthread_mutex_t mutex
static float a[EQ_BANDS][2]
void eq_set_bands(const double *values)
char * get_string(const char *section, const char *name)
static void bp2(float *a, float *b, float fc, float q)
double get_double(const char *section, const char *name)
void eq_filter(float *data, int samples)
static float b[EQ_BANDS][2]
void set_string(const char *section, const char *name, const char *value)
EXPORT void hook_associate(const char *name, HookFunction func, void *user)
#define hook_dissociate(n, f)
void eq_set_band(int band, double value)
EXPORT char * double_array_to_string(const double *array, int count)
EXPORT bool_t string_to_double_array(const char *string, double *array, int count)
bool_t get_bool(const char *section, const char *name)
static float wqv[MAX_CHANNELS][EQ_BANDS][2]
void eq_get_bands(double *values)
double eq_get_band(int band)
static const float CF[EQ_BANDS]
void eq_set_format(int new_channels, int new_rate)
static void eq_update(void *data, void *user)