More than 2 taps in scalar IIR
Hi,
I have been tinkering with the scalar iir filter library function for a couple of days but I cannot seem to figure what is going wrong.
I tested the filter code attached in the following post:
https://ez.analog.com/dsp/f/q-a/103284/scalar-iir-filter-problem
It works fine. However when I want to increase the number of taps of a_coeffs and b_coeffs it stops working, even if the added taps are zeros.
For instance, the following code snippet works fine:
#define TAPS (2)
const float pm a_coeffs[TAPS] = {-0.91159368625535, 1.9075008174364765};
const float pm b_coeffs[TAPS+1] = {0.0010232172047183973, 0.0020464344094367946, 0.0010232172047183973};
float dm states[TAPS+1] = {{0}};
void filter (float *input, float *output, int nSamples)
{
for (int i = 0; i < nSamples; i++)
{
output[nSample] = iir(input[nSample], a_coeffs, b_coeffs, states, TAPS);
}
}
However if I change the coeffs to the following:
#define TAPS (3)
const float pm a_coeffs[TAPS] = {0.0, -0.91159368625535, 1.9075008174364765};
const float pm b_coeffs[TAPS+1] = {0.0, 0.0010232172047183973, 0.0020464344094367946, 0.0010232172047183973};
I expect to have the exact same output. Instead I get no sound.
Is there something wrong there I didn't catch?
Thank you for your help!
Thomas
dsp
sharc
21489
dsp&processors
library
dsp library
Show More
Ok I realised that the size of my states array was incorrect in my code, this solved the problem.
However I realised that if you generate you coefficients with MATLAB or any online biquad filter coefficients generator, you have to explicitly multiply your a_coeffs by -1 for the iir scalar api to work, otherwise you will hear no sound.
Please log in to reply.