From 8c30eccb27c6ed75e55e901cc99f358b6b443050 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Tue, 15 Feb 2022 17:13:49 +0100 Subject: [PATCH] Add an identity function for biquad coefficients --- plugins/diopser/src/filter.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/plugins/diopser/src/filter.rs b/plugins/diopser/src/filter.rs index 6a44a12a..63ae52e9 100644 --- a/plugins/diopser/src/filter.rs +++ b/plugins/diopser/src/filter.rs @@ -41,13 +41,7 @@ impl Default for Biquad { /// Before setting constants the filter should just act as an identity function. fn default() -> Self { Self { - coefficients: BiquadCoefficients { - b0: 1.0, - b1: 0.0, - b2: 0.0, - a1: 0.0, - a2: 0.00, - }, + coefficients: BiquadCoefficients::identity(), s1: 0.0, s2: 0.0, } @@ -67,6 +61,17 @@ impl Biquad { } impl BiquadCoefficients { + /// Filter coefficients that would cause the sound to be passed through as is. + pub fn identity() -> Self { + Self { + b0: 1.0, + b1: 0.0, + b2: 0.0, + a1: 0.0, + a2: 0.0, + } + } + /// Compute the coefficients for an all-pass filter. /// /// Based on .