From 5f7998e6f2c458e25298f6d26a883d5d31fa718f Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 30 May 2023 13:43:06 -0500 Subject: [PATCH] synthio: improve rounding in biquad this removes a marked DC offset and may cure the 'pops' problem. --- shared-module/synthio/Biquad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-module/synthio/Biquad.c b/shared-module/synthio/Biquad.c index d8cf0d7889..d6cdb3168f 100644 --- a/shared-module/synthio/Biquad.c +++ b/shared-module/synthio/Biquad.c @@ -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) { 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; x0 = input;