**diff options**

author | Thom Johansen <thomj@rockbox.org> | 2006-04-11 13:49:05 +0000 |
---|---|---|

committer | Thom Johansen <thomj@rockbox.org> | 2006-04-11 13:49:05 +0000 |

commit | 8238b49c747afaf462ab5bdd45a37417eeae4dd9 (patch) | |

tree | 565d7ea84451eaa2eae3afbf6f9e481d95ff5d25 /apps/eq.c | |

parent | 6bd1f143facb6b832bd22a22020cfc6ae4540601 (diff) | |

download | rockbox-8238b49c747afaf462ab5bdd45a37417eeae4dd9.tar.gz rockbox-8238b49c747afaf462ab5bdd45a37417eeae4dd9.zip |

New crossfeed complete with no volume reducing bugs. Feedback on all the

new options is appreciated. Thanks to Dan Everton for the settings/GUI
code.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9609 a1c6a512-1295-4272-9138-f99709370657

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) return (dbtoatab[pos] << 16) + frac*diff; } +/* Calculate first order shelving filter coefficients. + cutoff is a value from 0 to 0x80000000, where 0 represents 0 hz and + 0x80000000 represents nyquist (samplerate/2). + ad is gain at 0 hz, and an is gain at Nyquist frequency. Both are s3.27 + format. + c is a pointer where the coefs will be stored. The coefs are s0.31 format. + Note that the filter is not compatible with the eq_filter routine. + */ +void filter_bishelf_coefs(unsigned long cutoff, long ad, long an, int32_t *c) +{ + const long one = 1 << 27; + long a0, a1; + long b0, b1; + long s, cs; + s = fsincos(cutoff, &cs) >> 4; + cs = one + (cs >> 4); + + /* For max A = 4 (24 dB) */ + b0 = (FRACMUL(an, cs) << 4) + (FRACMUL(ad, s) << 4); + b1 = (FRACMUL(ad, s) << 4) - (FRACMUL(an, cs) << 4); + a0 = s + cs; + a1 = s - cs; + + c[0] = DIV64(b0, a0, 31); + c[1] = DIV64(b1, a0, 31); + c[2] = -DIV64(a1, a0, 31); +} + /* Calculate second order section peaking filter coefficients. cutoff is a value from 0 to 0x80000000, where 0 represents 0 hz and 0x80000000 represents nyquist (samplerate/2). |