# Question regarding filter implementation - Audio EQ Cookbook

Some of you may know the infamous Audio EQ Cookbook. You can take a look here.

We tried to implement the functions there to achieve a implementation for a Lowpassfilter. However, when we try to lower our variable cutoff-frequency, we have some issues. With decreasing cutoff-frequency the signal is increasing in volume. Reaching a distinct treshold at around 4000- 6000Hz the filter stops working, because it computes samplevalues that are ever increasing, reaching around 2000000 shortly after lowering the cutoff frequency.

We checked our code multiple times,and the functions from the Cookbook should be right. If someone wants to see the code i can hand it to you later.

For any hints or solution we are more than thankful.

EDIT: The important part of the code.

float Filter::processFilter(float sample)
{
float unprocessed = sample;

float processed = (unprocessed) + (computeB1() * x_n_1) +
(computeB2() * x_n_2) - (computeA1() * y_n_1)
-(computeA2() * y_n_2);

x_n_2 = x_n_1;
x_n_1 = unprocessed;

y_n_2 = y_n_1;
y_n_1 = processed;

return processed;
}

• What's your Q? Your implementation is in floating point? You could post the filter coefficients so we can see what's going on (or, equivalently, Q, f0, and your sampling frequency). – Matt L. Jan 26 '15 at 16:17
• That page, you provided, belongs to "Robert Bristow-Johnson" so you better ask him, as he is a member here :) – Fat32 Jan 26 '15 at 16:20
• Q was 1 when the problem occured. The implementation is in c++ with float type. Sampling frequency is 48000. And f0 is 5355 and every value below that. – amaik Jan 26 '15 at 16:23
• I don't understand the downvote, if some information is missing i can provide, but just downvote the question is not helpful, thanks. – amaik Jan 26 '15 at 16:24
• @amaik: From the cookbook you get coefficients a0, a1, a2, b0, b1, and b2. Now you divide all coefficients by a0, and that's it. So the final b0 that you use is the original b0 divided by a0, etc. – Matt L. Jan 27 '15 at 9:10

With the values you provided ($Q=1$, $f_0=5355\,\text{Hz}$, and $F_s=48\,\text{kHz}$) I get the following filter coefficients from the Cookbook formulas:

b =

0.11789
0.23578
0.11789

a =

1.32248
-1.52844
0.67752


Note that the formulas give you denominator coefficients that are not normalized. Many implementations use $a_0=1$, which can be easily achieved by dividing numerator and denominator coefficients by $a_0=1.32248$.

The maximum pole radius of this filter is $0.72$, which means that we're not at all close to the unit circle, so stability shouldn't be an issue, no matter which implementation you use.

You can add more information if you like, but from what I know up to now, the most likely problem is a bug in your code.

Just test your filtering routine by using as input sequence x=1,0,0,...,, which should give the following output (the impulse response):

ans =

8.9144e-02
2.8131e-01
3.6860e-01
2.8188e-01
1.3694e-01
1.3860e-02
-5.4140e-02
-6.9672e-02
-5.2786e-02
-2.5313e-02
-2.2122e-03
1.0411e-02
1.3166e-02
9.8827e-03
4.6767e-03
3.4194e-04
-2.0007e-03
-2.4875e-03
-1.8499e-03
-8.6361e-04
-5.0389e-05

• Ok, Thank you. I'll check again for bugs. Just one more question. y[n] does specify the effected signal, whilst x[n] the uneffected signal, doesn't. – amaik Jan 26 '15 at 16:52
• @amaik: Yes, $x[n]$ is the input sequence, and $y[n]$ is the output sequence. – Matt L. Jan 26 '15 at 16:57
• Thanks again. I checked the computation of the coefficients and we have the same as you posted. I edited the question and added the important part of the code. What may be false is the output sequence? I don't know. – amaik Jan 26 '15 at 17:35
• @amaik: OK, I added the output signal for an impulse as input signal. Compare that with what you're routine computes. – Matt L. Jan 26 '15 at 17:41