Hello,
I have found fixed point implementation of Goertzel algorithm in book
“Real – Time Digital Signal Processing – Implementations and
Applications”. I will paste here a part of code responsible bor
computing recursive path.
void gFilter (short *d, short in, short coef)
{
long AC0;
d[0] = in >> 7; // Get input with scale down by 7 bit
AC0 = (long) d[1] * coef;
AC0 >>= 14;
AC0 -= d[2];
d[0] += (short)AC0;
d[2] = d[1]; // Update delay-line buffer
d[1] = d[0];
}
Book explains that this operation (AC0 >>= 14) aligns multiplication
product to be stored in Q15 format. I have read in a few places about Q15
numbers multiplication and they all specified that after multiplication
you have to perform shift right by 15. I don’t understand why AC0 is
shifted by 14 not by 15. Similar operation is performed in non recursive
part of code responsible for computing Goertzel output.