Hello,
I am using this FIR_filter function shown below for the 12 filter coefficients but now I want to use
this 12 coefficients FIR_filter function for the 32 coefficients purpose I made the changes but I am not sure if it right!!
int16_t vs_filter(int16_t sample)
{
static int16_t buf[32];
static int offset = 0;
int32_t z;
int i;
buf[offset] = sample;
z = mul16(coeffs[11], buf[(offset - 11) & 0x1F]);
for (i = 0; i < 11; i++)
z += mul16(coeffs[i], buf[(offset - i) & 0x1F] + buf[(offset - 22 + i) & 0x1F]);
offset = (offset + 1) & 0x1F;
return z >> 15;
}
Needed:for 32 coefficients
int FIR_filter(int sample)
{
static int buf[32];
static int offset = 0;
long z;
int i;
buf[offset] = sample;
z = mul16(coeffs[31], buf[(offset - 11) & 0x1F]);
for (i = 0; i < 31; i++)
z += mul16(coeffs[i], buf[(offset - i) & 0x1F] + buf[(offset - 22 + i) & 0x1F]);
offset = (offset + 1) & 0x1F;
return z >> 15;
}
can someone explain if the above will work for 32 coefficeints or anything else is needed.
Also what does these mean 1)buf[(offset - 11) & 0x1F]) 2) buf[(offset - 22 + i) & 0x1F]
Thankyou.