From 2ddf0c10ed975f030d434913dd7a88b5dc3cd927 Mon Sep 17 00:00:00 2001 From: Andreya-Autumn Date: Tue, 23 Jul 2024 20:26:44 +0200 Subject: [PATCH] improve noise AM --- .../sst/voice-effects/modulation/NoiseAM.h | 72 +++++++++++++++---- 1 file changed, 58 insertions(+), 14 deletions(-) diff --git a/include/sst/voice-effects/modulation/NoiseAM.h b/include/sst/voice-effects/modulation/NoiseAM.h index e371f42..f072176 100644 --- a/include/sst/voice-effects/modulation/NoiseAM.h +++ b/include/sst/voice-effects/modulation/NoiseAM.h @@ -204,7 +204,6 @@ template struct NoiseAM : core::VoiceEffectTemplateBase struct NoiseAM : core::VoiceEffectTemplateBase 0) + { + noiseL[i] *= -1; + } + if (datainR[i] > 0) + { + noiseR[i] *= -1; + } + // this keeps the combined peaks under control and saturates the signal a bit + + // this is the overshoot calculation + overL = std::max(envL - threshold, 0.f); + overR = std::max(envR - threshold, 0.f); + } + else + { + // which is reversed in unipolar mode, just so it plays nicer with asym waveshapes + overL = std::min(envL + threshold, 0.f); + overR = std::min(envR + threshold, 0.f); + // runaway peaks are a bit less problematic here so don't mess with the noise + } - noiseL[i] *= overL; - noiseR[i] *= overR; + noiseL[i] *= depth * overL; + noiseR[i] *= depth * overR; dataoutL[i] = datainL[i] + noiseL[i]; dataoutR[i] = datainR[i] + noiseR[i]; @@ -251,7 +280,6 @@ template struct NoiseAM : core::VoiceEffectTemplateBase struct NoiseAM : core::VoiceEffectTemplateBase 0) + { + noise[i] *= -1; + } - auto over = std::max(env - threshold, 0.f); + over = std::max(env - threshold, 0.f); + } + else + { + over = std::min(env + threshold, 0.f); + } - noise[i] *= over; + noise[i] *= depth * over; dataout[i] = datain[i] + noise[i]; }