I searched on Google but did not find any useful examples?
UPDATE
When I convert the transfer function calculation result to an integer and check for overflow, 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 ;
< p>Since hitting the boundary of the range with this processing is a natural side effect, you should use one of these methods to deal with it (the list should not be complete):
>Make sure your input signal is sufficient Quiet and/or shift the value a few places to the right to provide margin for large values on the output>Use higher number of bits for the output signal, such as 24-bit PCM>Use floating-point PCM output signal to outside the PCM sampling range Loss of accuracy
I have samples from ffmpeg, usually it is a 16-bit sample (short type), I used iir bandpass filter with dbGain, as here As mentioned, after filtering, I sometimes get a short overflow. The result is that some noise calculated sample values come out from 32767 / -32767. Is there a way to escape audio pcm sample editing. Is there any way?
I searched on Google but did not find any useful examples?
UPDATE
When I convert the transfer function calculation result to an integer and check for overflow, 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 ;
The 16-bit PCM samples must be in the range of [-32768 .. 32767]. If you use math (in your case, biquad filter If you apply a positive gain, this is an inevitable result.
Because of the use of this processing, the hit range boundary is one This is a natural side effect, so you should use one of these methods to deal with it (the list should not be complete):
>Make sure your input signal is quiet enough and/or shift the value a few places to the right, In order to provide margin for large values on the output>Use a higher number of bits for the output signal, such as 24-bit PCM>Use floating-point PCM to output the signal to the loss of precision outside the PCM sampling range