diff options
Diffstat (limited to 'apps/eq.c')
-rw-r--r-- | apps/eq.c | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -187,6 +187,34 @@ static long dbtoA(long db) | |||
187 | return (dbtoatab[pos] << 16) + frac*diff; | 187 | return (dbtoatab[pos] << 16) + frac*diff; |
188 | } | 188 | } |
189 | 189 | ||
190 | /* Calculate first order shelving filter coefficients. | ||
191 | cutoff is a value from 0 to 0x80000000, where 0 represents 0 hz and | ||
192 | 0x80000000 represents nyquist (samplerate/2). | ||
193 | ad is gain at 0 hz, and an is gain at Nyquist frequency. Both are s3.27 | ||
194 | format. | ||
195 | c is a pointer where the coefs will be stored. The coefs are s0.31 format. | ||
196 | Note that the filter is not compatible with the eq_filter routine. | ||
197 | */ | ||
198 | void filter_bishelf_coefs(unsigned long cutoff, long ad, long an, int32_t *c) | ||
199 | { | ||
200 | const long one = 1 << 27; | ||
201 | long a0, a1; | ||
202 | long b0, b1; | ||
203 | long s, cs; | ||
204 | s = fsincos(cutoff, &cs) >> 4; | ||
205 | cs = one + (cs >> 4); | ||
206 | |||
207 | /* For max A = 4 (24 dB) */ | ||
208 | b0 = (FRACMUL(an, cs) << 4) + (FRACMUL(ad, s) << 4); | ||
209 | b1 = (FRACMUL(ad, s) << 4) - (FRACMUL(an, cs) << 4); | ||
210 | a0 = s + cs; | ||
211 | a1 = s - cs; | ||
212 | |||
213 | c[0] = DIV64(b0, a0, 31); | ||
214 | c[1] = DIV64(b1, a0, 31); | ||
215 | c[2] = -DIV64(a1, a0, 31); | ||
216 | } | ||
217 | |||
190 | /* Calculate second order section peaking filter coefficients. | 218 | /* Calculate second order section peaking filter coefficients. |
191 | cutoff is a value from 0 to 0x80000000, where 0 represents 0 hz and | 219 | cutoff is a value from 0 to 0x80000000, where 0 represents 0 hz and |
192 | 0x80000000 represents nyquist (samplerate/2). | 220 | 0x80000000 represents nyquist (samplerate/2). |