@nctnico Thank you for the confirmation.
@hamster_nz Ah ok, that makes sense. So DSP is not my strong suit at all. I've read a book about it once but that's it. In regards to the filter having a greater than one gain causing overflows. I'm using Matlab to design my filter and it gives small fractional coefficients. To quantize these I gain them up by some power of two. Then at the end I divide the value of the accumulator by that same power of two. So even though I gain up the coefficients(thus increasing the gain of my filter) there wont be overflows because I gain it back down at the end thus avoiding overflows on the output. Is that correct assuming my original filter doesn't have a gain greater than unity? Or is the overflow you're mentioning happening some where else?
Thank you!
It can become a problem like this:
Imagine you have a FIR filter with a kernel of five coefficients : ( -0.2, 0.1, 0.7, 0.1, -0.2 )
The DC gain is -0.2 + 0.1 + 0.7 + 0.1 0 - 0.2 = 0.9, so less than unity, so it looks like it should be safe from underflows and overflows.
You might choose to implement it with a signed 16-bit value, multiplied by five signed 16-bit fixed point coefficients, totaling into a 32-bit accumulator. For a DC input the output will be no greater than about +/- 30,000 counts.
However, for some inputs (e.g. a sine wave at 1/4th the sample frequency) it will have gain greater than unity - in fact it will have at f/4 it will have a gain of 1.3x - any input at this frequency that is more than +/- 25206 counts will cause an overflow.
The same thing can happen if your filter causes different frequencies to be delayed by different amounts. What looks to be safe at first glance isn't, for some pathological inputs.
I most cases, having some extra dynamic range up your sleeve is usually helpful.