diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/eq.c | 28 |
1 files changed, 22 insertions, 6 deletions
@@ -217,12 +217,28 @@ void eq_hs_coefs(unsigned long cutoff, unsigned long Q, long db, long *c) | |||
217 | void eq_filter(long **x, struct eqfilter *f, unsigned num, | 217 | void eq_filter(long **x, struct eqfilter *f, unsigned num, |
218 | unsigned channels, unsigned shift) | 218 | unsigned channels, unsigned shift) |
219 | { | 219 | { |
220 | /* TODO: Implement generic filtering routine. */ | 220 | unsigned c, i; |
221 | (void)x; | 221 | long long acc; |
222 | (void)f; | 222 | |
223 | (void)num; | 223 | /* Direct form 1 filtering code. |
224 | (void)channels; | 224 | y[n] = b0*x[i] + b1*x[i - 1] + b2*x[i - 2] + a1*y[i - 1] + a2*y[i - 2], |
225 | (void)shift; | 225 | where y[] is output and x[] is input. |
226 | */ | ||
227 | |||
228 | for (c = 0; c < channels; c++) { | ||
229 | for (i = 0; i < num; i++) { | ||
230 | acc = (long long) x[c][i] * f->coefs[0]; | ||
231 | acc += (long long) f->history[c][0] * f->coefs[1]; | ||
232 | acc += (long long) f->history[c][1] * f->coefs[2]; | ||
233 | acc += (long long) f->history[c][2] * f->coefs[3]; | ||
234 | acc += (long long) f->history[c][3] * f->coefs[4]; | ||
235 | f->history[c][1] = f->history[c][0]; | ||
236 | f->history[c][0] = x[c][i]; | ||
237 | f->history[c][3] = f->history[c][2]; | ||
238 | x[c][i] = (acc << shift) >> 32; | ||
239 | f->history[c][2] = x[c][i]; | ||
240 | } | ||
241 | } | ||
226 | } | 242 | } |
227 | #endif | 243 | #endif |
228 | 244 | ||