I have samples which come from ffmpeg, very often it is 16 bit samples (short type), i have used iir band pass filter with dbGain as described here, after filtering i sometimes got a short type overflow and result of it is some noise when calculated sample value go out from 32767/-32767, Is any way to escape audio pcm sample clipping. May be exists any approaches?
I have googled but not found any worked example?
UPDATE
When i cast transfer function calculation result to integer and check 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;