synthio: improve rounding in biquad

this removes a marked DC offset and may cure the 'pops' problem.
This commit is contained in:
Jeff Epler 2023-05-30 13:43:06 -05:00
parent 8a85deb1e2
commit 5f7998e6f2
No known key found for this signature in database
GPG Key ID: D5BF15AB975AB4DE

View File

@ -132,7 +132,7 @@ void synthio_biquad_filter_samples(biquad_filter_state *st, int32_t *out0, const
for (size_t n = n0; n; --n, in += n_channels, out += n_channels) { for (size_t n = n0; n; --n, in += n_channels, out += n_channels) {
int32_t input = *in; int32_t input = *in;
int32_t output = (b0 * input + b1 * x0 + b2 * x1 - a1 * y0 - a2 * y1) >> BIQUAD_SHIFT; int32_t output = (b0 * input + b1 * x0 + b2 * x1 - a1 * y0 - a2 * y1 + (1 << (BIQUAD_SHIFT - 1))) >> BIQUAD_SHIFT;
x1 = x0; x1 = x0;
x0 = input; x0 = input;