diff options
Diffstat (limited to 'apps/eq.c')
-rw-r--r-- | apps/eq.c | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -138,13 +138,13 @@ static long dbtoA(long db) | |||
138 | db is s15.16 fixed point and describes gain/attenuation at peak freq. | 138 | db is s15.16 fixed point and describes gain/attenuation at peak freq. |
139 | c is a pointer where the coefs will be stored. | 139 | c is a pointer where the coefs will be stored. |
140 | */ | 140 | */ |
141 | void eq_pk_coefs(unsigned long cutoff, unsigned long Q, long db, long *c) | 141 | void eq_pk_coefs(unsigned long cutoff, unsigned long Q, long db, int32_t *c) |
142 | { | 142 | { |
143 | const long one = 1 << 28; /* s3.28 */ | 143 | const long one = 1 << 28; /* s3.28 */ |
144 | const long A = dbtoA(db); | 144 | const long A = dbtoA(db); |
145 | const long alpha = DIV64(fsin(cutoff), 2*Q, 15); /* s1.30 */ | 145 | const long alpha = DIV64(fsin(cutoff), 2*Q, 15); /* s1.30 */ |
146 | long a0, a1, a2; /* these are all s3.28 format */ | 146 | int32_t a0, a1, a2; /* these are all s3.28 format */ |
147 | long b0, b1, b2; | 147 | int32_t b0, b1, b2; |
148 | 148 | ||
149 | /* possible numerical ranges listed after each coef */ | 149 | /* possible numerical ranges listed after each coef */ |
150 | b0 = one + FRACMUL(alpha, A); /* [1.25..5] */ | 150 | b0 = one + FRACMUL(alpha, A); /* [1.25..5] */ |
@@ -161,7 +161,7 @@ void eq_pk_coefs(unsigned long cutoff, unsigned long Q, long db, long *c) | |||
161 | } | 161 | } |
162 | 162 | ||
163 | /* Calculate coefficients for lowshelf filter */ | 163 | /* Calculate coefficients for lowshelf filter */ |
164 | void eq_ls_coefs(unsigned long cutoff, unsigned long Q, long db, long *c) | 164 | void eq_ls_coefs(unsigned long cutoff, unsigned long Q, long db, int32_t *c) |
165 | { | 165 | { |
166 | const long one = 1 << 24; /* s7.24 */ | 166 | const long one = 1 << 24; /* s7.24 */ |
167 | const long A = dbtoA(db); | 167 | const long A = dbtoA(db); |
@@ -169,8 +169,8 @@ void eq_ls_coefs(unsigned long cutoff, unsigned long Q, long db, long *c) | |||
169 | const long ap1 = (A >> 5) + one; | 169 | const long ap1 = (A >> 5) + one; |
170 | const long am1 = (A >> 5) - one; | 170 | const long am1 = (A >> 5) - one; |
171 | const long twosqrtalpha = 2*(FRACMUL(fsqrt(A >> 5, 24), alpha) << 1); | 171 | const long twosqrtalpha = 2*(FRACMUL(fsqrt(A >> 5, 24), alpha) << 1); |
172 | long a0, a1, a2; /* these are all s7.24 format */ | 172 | int32_t a0, a1, a2; /* these are all s7.24 format */ |
173 | long b0, b1, b2; | 173 | int32_t b0, b1, b2; |
174 | long cs = fcos(cutoff); | 174 | long cs = fcos(cutoff); |
175 | 175 | ||
176 | b0 = FRACMUL(A, ap1 - FRACMUL(am1, cs) + twosqrtalpha) << 2; | 176 | b0 = FRACMUL(A, ap1 - FRACMUL(am1, cs) + twosqrtalpha) << 2; |
@@ -188,7 +188,7 @@ void eq_ls_coefs(unsigned long cutoff, unsigned long Q, long db, long *c) | |||
188 | } | 188 | } |
189 | 189 | ||
190 | /* Calculate coefficients for highshelf filter */ | 190 | /* Calculate coefficients for highshelf filter */ |
191 | void eq_hs_coefs(unsigned long cutoff, unsigned long Q, long db, long *c) | 191 | void eq_hs_coefs(unsigned long cutoff, unsigned long Q, long db, int32_t *c) |
192 | { | 192 | { |
193 | const long one = 1 << 24; /* s7.24 */ | 193 | const long one = 1 << 24; /* s7.24 */ |
194 | const long A = dbtoA(db); | 194 | const long A = dbtoA(db); |
@@ -196,8 +196,8 @@ void eq_hs_coefs(unsigned long cutoff, unsigned long Q, long db, long *c) | |||
196 | const long ap1 = (A >> 5) + one; | 196 | const long ap1 = (A >> 5) + one; |
197 | const long am1 = (A >> 5) - one; | 197 | const long am1 = (A >> 5) - one; |
198 | const long twosqrtalpha = 2*(FRACMUL(fsqrt(A >> 5, 24), alpha) << 1); | 198 | const long twosqrtalpha = 2*(FRACMUL(fsqrt(A >> 5, 24), alpha) << 1); |
199 | long a0, a1, a2; /* these are all s7.24 format */ | 199 | int32_t a0, a1, a2; /* these are all s7.24 format */ |
200 | long b0, b1, b2; | 200 | int32_t b0, b1, b2; |
201 | long cs = fcos(cutoff); | 201 | long cs = fcos(cutoff); |
202 | 202 | ||
203 | b0 = FRACMUL(A, ap1 + FRACMUL(am1, cs) + twosqrtalpha) << 2; | 203 | b0 = FRACMUL(A, ap1 + FRACMUL(am1, cs) + twosqrtalpha) << 2; |