From 2908a8b56f94d87400a117ad75e2ffd9f3b2209a Mon Sep 17 00:00:00 2001 From: Geraint Date: Sun, 6 Jul 2025 10:08:14 +0100 Subject: [PATCH] Stereo energy compensation --- chorus.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/chorus.h b/chorus.h index 5b9bca9..6cbf5d1 100644 --- a/chorus.h +++ b/chorus.h @@ -97,8 +97,14 @@ struct ChorusSTFX : public BaseEffect { std::array multiIn, multiOut; std::array delaySamples; - auto dry = block.smooth(mix, [](double m){return 1 - m*m;}); - auto wet = block.smooth(mix, [](double m){return m*(2 - m)/std::sqrt(Sample(6));}); + auto wetDryFn = [](double mix, double width, bool isWet){ + // Equal-power wet/dry fade + double m = isWet ? std::sin(M_PI*mix/2) : std::cos(M_PI*mix/2); + // Compensate for extra energy from stereo + return m/std::sqrt(6*(1 + width*width/2)); + }; + auto dry = block.smooth(wetDryFn(mix.from(), stereo.from(), false), wetDryFn(mix.to(), stereo.to(), false)); + auto wet = block.smooth(wetDryFn(mix.from(), stereo.from(), true), wetDryFn(mix.to(), stereo.to(), true)); bool notMono = (config.outputChannels > 1); auto width = block.smooth(stereo);