annotate libaf/af_equalizer.c @ 8870:7538bf7e728d

halfpack now takes an optional argument, field, which tells it to keep only even lines (if 0) or only odd lines (if 1) rather than averaging pairs of lines. this may be useful for slightly improving performance or for dirty deinterlacing.
author rfelker
date Fri, 10 Jan 2003 14:12:07 +0000
parents d6f40a06867b
children 14090f7300a8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8073
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
1 /*=============================================================================
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
2 //
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
3 // This software has been released under the terms of the GNU Public
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
4 // license. See http://www.gnu.org/copyleft/gpl.html for details.
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
5 //
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
6 // Copyright 2001 Anders Johansson ajh@atri.curtin.edu.au
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
7 //
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
8 //=============================================================================
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
9 */
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
10
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
11 /* Equalizer filter, implementation of a 10 band time domain graphic
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
12 equalizer using IIR filters. The IIR filters are implemented using a
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
13 Direct Form II approach, but has been modified (b1 == 0 always) to
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
14 save computation.
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
15 */
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
16
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
17 #include <stdio.h>
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
18 #include <stdlib.h>
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
19
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
20 #include <unistd.h>
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
21 #include <inttypes.h>
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
22 #include <math.h>
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
23
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
24 #include "af.h"
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
25
8167
e8832e66babd New features:
anders
parents: 8073
diff changeset
26 #define L 2 // Storage for filter taps
e8832e66babd New features:
anders
parents: 8073
diff changeset
27 #define KM 10 // Max number of bands
8073
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
28
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
29 #define Q 1.2247449 /* Q value for band-pass filters 1.2247=(3/2)^(1/2)
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
30 gives 4dB suppression @ Fc*2 and Fc/2 */
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
31
8607
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
32 /* Center frequencies for band-pass filters
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
33 The different frequency bands are:
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
34 nr. center frequency
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
35 0 31.25 Hz
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
36 1 62.50 Hz
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
37 2 125.0 Hz
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
38 3 250.0 Hz
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
39 4 500.0 Hz
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
40 5 1.000 kHz
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
41 6 2.000 kHz
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
42 7 4.000 kHz
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
43 8 8.000 kHz
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
44 9 16.00 kHz
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
45 */
8073
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
46 #define CF {31.25,62.5,125,250,500,1000,2000,4000,8000,16000}
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
47
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
48 // Maximum and minimum gain for the bands
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
49 #define G_MAX +12.0
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
50 #define G_MIN -12.0
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
51
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
52 // Data for specific instances of this filter
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
53 typedef struct af_equalizer_s
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
54 {
8607
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
55 float a[KM][L]; // A weights
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
56 float b[KM][L]; // B weights
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
57 float wq[AF_NCH][KM][L]; // Circular buffer for W data
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
58 float g[AF_NCH][KM]; // Gain factor for each channel and band
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
59 int K; // Number of used eq bands
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
60 int channels; // Number of channels
8073
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
61 } af_equalizer_t;
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
62
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
63 // 2nd order Band-pass Filter design
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
64 static void bp2(float* a, float* b, float fc, float q){
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
65 double th= 2.0 * M_PI * fc;
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
66 double C = (1.0 - tan(th*q/2.0))/(1.0 + tan(th*q/2.0));
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
67
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
68 a[0] = (1.0 + C) * cos(th);
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
69 a[1] = -1 * C;
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
70
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
71 b[0] = (1.0 - C)/2.0;
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
72 b[1] = -1.0050;
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
73 }
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
74
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
75 // Initialization and runtime control
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
76 static int control(struct af_instance_s* af, int cmd, void* arg)
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
77 {
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
78 af_equalizer_t* s = (af_equalizer_t*)af->setup;
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
79
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
80 switch(cmd){
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
81 case AF_CONTROL_REINIT:{
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
82 int k =0;
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
83 float F[KM] = CF;
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
84
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
85 // Sanity check
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
86 if(!arg) return AF_ERROR;
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
87
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
88 af->data->rate = ((af_data_t*)arg)->rate;
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
89 af->data->nch = ((af_data_t*)arg)->nch;
8607
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
90 af->data->format = AF_FORMAT_NE | AF_FORMAT_F;
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
91 af->data->bps = 4;
8073
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
92
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
93 // Calculate number of active filters
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
94 s->K=KM;
8167
e8832e66babd New features:
anders
parents: 8073
diff changeset
95 while(F[s->K-1] > (float)af->data->rate/2.2)
8073
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
96 s->K--;
8167
e8832e66babd New features:
anders
parents: 8073
diff changeset
97
e8832e66babd New features:
anders
parents: 8073
diff changeset
98 if(s->K != KM)
8607
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
99 af_msg(AF_MSG_INFO,"[equalizer] Limiting the number of filters to"
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
100 " %i due to low sample rate.\n",s->K);
8073
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
101
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
102 // Generate filter taps
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
103 for(k=0;k<s->K;k++)
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
104 bp2(s->a[k],s->b[k],F[k]/((float)af->data->rate),Q);
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
105
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
106 // Calculate how much this plugin adds to the overall time delay
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
107 af->delay += 2000.0/((float)af->data->rate);
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
108
8607
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
109 return af_test_output(af,arg);
8073
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
110 }
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
111 case AF_CONTROL_COMMAND_LINE:{
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
112 float g[10]={0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0};
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
113 int i,j;
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
114 sscanf((char*)arg,"%f:%f:%f:%f:%f:%f:%f:%f:%f:%f", &g[0], &g[1],
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
115 &g[2], &g[3], &g[4], &g[5], &g[6], &g[7], &g[8] ,&g[9]);
8607
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
116 for(i=0;i<AF_NCH;i++){
8073
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
117 for(j=0;j<KM;j++){
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
118 ((af_equalizer_t*)af->setup)->g[i][j] =
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
119 pow(10.0,clamp(g[j],G_MIN,G_MAX)/20.0)-1.0;
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
120 }
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
121 }
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
122 return AF_OK;
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
123 }
8607
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
124 case AF_CONTROL_EQUALIZER_GAIN | AF_CONTROL_SET:{
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
125 float* gain = ((af_control_ext_t*)arg)->arg;
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
126 int ch = ((af_control_ext_t*)arg)->ch;
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
127 int k;
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
128 if(ch > AF_NCH || ch < 0)
8073
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
129 return AF_ERROR;
8607
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
130
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
131 for(k = 0 ; k<KM ; k++)
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
132 s->g[ch][k] = pow(10.0,clamp(gain[k],G_MIN,G_MAX)/20.0)-1.0;
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
133
8073
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
134 return AF_OK;
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
135 }
8607
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
136 case AF_CONTROL_EQUALIZER_GAIN | AF_CONTROL_GET:{
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
137 float* gain = ((af_control_ext_t*)arg)->arg;
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
138 int ch = ((af_control_ext_t*)arg)->ch;
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
139 int k;
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
140 if(ch > AF_NCH || ch < 0)
8073
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
141 return AF_ERROR;
8607
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
142
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
143 for(k = 0 ; k<KM ; k++)
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
144 gain[k] = log10(s->g[ch][k]+1.0) * 20.0;
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
145
8073
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
146 return AF_OK;
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
147 }
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
148 }
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
149 return AF_UNKNOWN;
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
150 }
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
151
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
152 // Deallocate memory
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
153 static void uninit(struct af_instance_s* af)
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
154 {
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
155 if(af->data)
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
156 free(af->data);
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
157 if(af->setup)
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
158 free(af->setup);
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
159 }
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
160
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
161 // Filter data through filter
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
162 static af_data_t* play(struct af_instance_s* af, af_data_t* data)
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
163 {
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
164 af_data_t* c = data; // Current working data
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
165 af_equalizer_t* s = (af_equalizer_t*)af->setup; // Setup
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
166 uint32_t ci = af->data->nch; // Index for channels
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
167 uint32_t nch = af->data->nch; // Number of channels
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
168
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
169 while(ci--){
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
170 float* g = s->g[ci]; // Gain factor
8607
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
171 float* in = ((float*)c->audio)+ci;
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
172 float* out = ((float*)c->audio)+ci;
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
173 float* end = in + c->len/4; // Block loop end
8073
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
174
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
175 while(in < end){
8607
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
176 register uint32_t k = 0; // Frequency band index
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
177 register float yt = *in; // Current input sample
8073
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
178 in+=nch;
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
179
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
180 // Run the filters
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
181 for(;k<s->K;k++){
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
182 // Pointer to circular buffer wq
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
183 register float* wq = s->wq[ci][k];
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
184 // Calculate output from AR part of current filter
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
185 register float w=yt*s->b[k][0] + wq[0]*s->a[k][0] + wq[1]*s->a[k][1];
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
186 // Calculate output form MA part of current filter
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
187 yt+=(w + wq[1]*s->b[k][1])*g[k];
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
188 // Update circular buffer
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
189 wq[1] = wq[0];
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
190 wq[0] = w;
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
191 }
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
192 // Calculate output
8607
d6f40a06867b Changes includes:
anders
parents: 8167
diff changeset
193 *out=yt/(4.0*10.0);
8073
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
194 out+=nch;
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
195 }
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
196 }
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
197 return c;
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
198 }
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
199
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
200 // Allocate memory and set function pointers
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
201 static int open(af_instance_t* af){
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
202 af->control=control;
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
203 af->uninit=uninit;
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
204 af->play=play;
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
205 af->mul.n=1;
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
206 af->mul.d=1;
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
207 af->data=calloc(1,sizeof(af_data_t));
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
208 af->setup=calloc(1,sizeof(af_equalizer_t));
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
209 if(af->data == NULL || af->setup == NULL)
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
210 return AF_ERROR;
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
211 return AF_OK;
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
212 }
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
213
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
214 // Description of this filter
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
215 af_info_t af_info_equalizer = {
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
216 "Equalizer audio filter",
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
217 "equalizer",
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
218 "Anders",
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
219 "",
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
220 AF_FLAGS_NOT_REENTRANT,
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
221 open
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
222 };
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
223
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
224
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
225
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
226
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
227
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
228
c0e556f9986b Adding equalizer filter + some cosmetics
anders
parents:
diff changeset
229