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;
}
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