From 0dd093c84539ae1d472763b06f63ff2556a2dd1a Mon Sep 17 00:00:00 2001 From: Nick Donaldson Date: Fri, 23 Feb 2024 16:22:06 -0700 Subject: [PATCH 1/2] Fix bug with ladder filter feedback and first stage --- Source/Filters/ladder.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Source/Filters/ladder.cpp b/Source/Filters/ladder.cpp index d380bde3..ac1d2a22 100644 --- a/Source/Filters/ladder.cpp +++ b/Source/Filters/ladder.cpp @@ -25,7 +25,7 @@ // Huovilainen New Moog (HNM) model as per CMJ jun 2006 // Richard van Hoesel, v. 1.03, Feb. 14 2021 // v1.7 (Infrasonic/Daisy) add configurable filter mode -// v1.6 (Infrasonic/Daisy) removes polyphase FIR, uses 2x linear +// v1.6 (Infrasonic/Daisy) removes polyphase FIR, uses 4x linear // oversampling for performance reasons // v1.5 adds polyphase FIR or Linear interpolation // v1.4 FC extended to 18.7kHz, max res to 1.8, 4x oversampling, @@ -75,15 +75,14 @@ float LadderFilter::Process(float in) float interp = 0.0f; for(size_t os = 0; os < kInterpolation; os++) { - float u = (interp * oldinput_ + (1.0f - interp) * input) - - (z1_[3] - pbg_ * input) * K_ * Qadjust_; + float in_interp = (interp * oldinput_ + (1.0f - interp) * input); + float u = in_interp - (z1_[3] - pbg_ * in_interp) * K_ * Qadjust_; u = fast_tanh(u); float stage1 = LPF(u, 0); float stage2 = LPF(stage1, 1); float stage3 = LPF(stage2, 2); float stage4 = LPF(stage3, 3); - total += weightedSumForCurrentMode( - {input, stage1, stage2, stage3, stage4}) + total += weightedSumForCurrentMode({u, stage1, stage2, stage3, stage4}) * kInterpolationRecip; interp += kInterpolationRecip; } From 20107ecbe149cd0a3b408f9d13e1930851b271da Mon Sep 17 00:00:00 2001 From: Nick Donaldson Date: Fri, 19 Apr 2024 08:40:41 -0600 Subject: [PATCH 2/2] Use scaled drive factor in ladder Proper PBG compensation depends on using scaled drive --- Source/Filters/ladder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Filters/ladder.cpp b/Source/Filters/ladder.cpp index ac1d2a22..922997c9 100644 --- a/Source/Filters/ladder.cpp +++ b/Source/Filters/ladder.cpp @@ -70,7 +70,7 @@ void LadderFilter::Init(float sample_rate) float LadderFilter::Process(float in) { - float input = in * drive_; + float input = in * drive_scaled_; float total = 0.0f; float interp = 0.0f; for(size_t os = 0; os < kInterpolation; os++)