From 8238b49c747afaf462ab5bdd45a37417eeae4dd9 Mon Sep 17 00:00:00 2001
From: Thom Johansen
Date: Tue, 11 Apr 2006 13:49:05 +0000
Subject: 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
---
apps/eq.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
(limited to 'apps/eq.c')
diff --git a/apps/eq.c b/apps/eq.c
index 8fb065aa09..5011f32e5f 100644
--- a/apps/eq.c
+++ b/apps/eq.c
@@ -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).
--
cgit v1.2.3