I have samples that come from ffmpeg, very often these are 16-bit samples (short type), I used an iir bandwidth filter with dbGain as described here , after filtering I sometimes got a short-term overflow, and there was some noise as a result when the computed sample value is out of 32767 / -32767. Is there a way to avoid clipping pcm audio samples. Can there be any approaches?
I have googled but no working example found?
UPDATE
When I pass the result of the calculation of the transfer function to an integer and check the overflow, then noise still occurs:
int result = A1 * ((int) Rx) + A2 * ((int) Rxx) + A3 * ((int) Rxxx) - B1 * ((int) Ryy) - B2 * ((int) Ryyy); if (result > 32767) result = 32767; if (result < -32700) result = -32700; y = (short) result;
source share