summaryrefslogtreecommitdiff
path: root/apps/eq.c
diff options
context:
space:
mode:
authorThom Johansen <thomj@rockbox.org>2006-01-29 17:52:13 +0000
committerThom Johansen <thomj@rockbox.org>2006-01-29 17:52:13 +0000
commit65721f0b3573460d306528ff34aa395c45e94ea3 (patch)
treece1476b13c66ba067d3944fabaac949aa78afb11 /apps/eq.c
parenta371ec3e77f7fcc6d498c747ad46ede7900e0bde (diff)
Slight change of coef format. Removed erronous hard code of channel
number in EQ filtering routine and added some minor changes. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8486 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/eq.c')
-rw-r--r--apps/eq.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/apps/eq.c b/apps/eq.c
index 8ad886fc0c..3d2f8d133d 100644
--- a/apps/eq.c
+++ b/apps/eq.c
@@ -24,6 +24,8 @@
Slightly faster calculation can be done by deriving forms which use tan()
instead of cos() and sin(), but the latter are far easier to use when doing
fixed point math, and performance is not a big point in the calculation part.
+ All the 'a' filter coefficients are negated so we can use only additions
+ in the filtering equation.
We realise the filters as a second order direct form 1 structure. Direct
form 1 was chosen because of better numerical properties for fixed point
implementations.
@@ -153,8 +155,8 @@ void eq_pk_coefs(unsigned long cutoff, unsigned long Q, long db, long *c)
c[0] = DIV64(b0, a0, 28);
c[1] = DIV64(b1, a0, 28);
c[2] = DIV64(b2, a0, 28);
- c[3] = DIV64(a1, a0, 28);
- c[4] = DIV64(a2, a0, 28);
+ c[3] = DIV64(-a1, a0, 28);
+ c[4] = DIV64(-a2, a0, 28);
}
/* Calculate coefficients for lowshelf filter */
@@ -180,8 +182,8 @@ void eq_ls_coefs(unsigned long cutoff, unsigned long Q, long db, long *c)
c[0] = DIV64(b0, a0, 24);
c[1] = DIV64(b1, a0, 24);
c[2] = DIV64(b2, a0, 24);
- c[3] = DIV64(a1, a0, 24);
- c[4] = DIV64(a2, a0, 24);
+ c[3] = DIV64(-a1, a0, 24);
+ c[4] = DIV64(-a2, a0, 24);
}
/* Calculate coefficients for highshelf filter */
@@ -207,8 +209,8 @@ void eq_hs_coefs(unsigned long cutoff, unsigned long Q, long db, long *c)
c[0] = DIV64(b0, a0, 24);
c[1] = DIV64(b1, a0, 24);
c[2] = DIV64(b2, a0, 24);
- c[3] = DIV64(a1, a0, 24);
- c[4] = DIV64(a2, a0, 24);
+ c[3] = DIV64(-a1, a0, 24);
+ c[4] = DIV64(-a2, a0, 24);
}
#if !defined(CPU_COLDFIRE) || defined(SIMULATOR)