1
0

Stereo energy compensation

This commit is contained in:
Geraint 2025-07-06 10:08:14 +01:00
parent 4782f1ff32
commit 2908a8b56f

View File

@ -97,8 +97,14 @@ struct ChorusSTFX : public BaseEffect {
std::array<Sample, 6> multiIn, multiOut; std::array<Sample, 6> multiIn, multiOut;
std::array<Sample, 6> delaySamples; std::array<Sample, 6> delaySamples;
auto dry = block.smooth(mix, [](double m){return 1 - m*m;}); auto wetDryFn = [](double mix, double width, bool isWet){
auto wet = block.smooth(mix, [](double m){return m*(2 - m)/std::sqrt(Sample(6));}); // 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); bool notMono = (config.outputChannels > 1);
auto width = block.smooth(stereo); auto width = block.smooth(stereo);