From cff31af32831f6e60517714ce76cbaf3b4040118 Mon Sep 17 00:00:00 2001 From: Blitblank Date: Wed, 14 Jan 2026 21:11:23 -0600 Subject: [PATCH] clipping fix --- src/synth/Synth.cpp | 2 ++ src/synth/Synth.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/synth/Synth.cpp b/src/synth/Synth.cpp index 90ab889..2315e80 100644 --- a/src/synth/Synth.cpp +++ b/src/synth/Synth.cpp @@ -92,6 +92,8 @@ void Synth::process(float* out, uint32_t nFrames, uint32_t sampleRate) { for(Voice& v : voices_) { mix += v.process(params, triggered); } + mix /= 4.0f; // for number of voices to prevent clipping + mix = tanh(mix); // really prevents clipping sampleOut = mix; diff --git a/src/synth/Synth.h b/src/synth/Synth.h index 5a22b93..f373cca 100644 --- a/src/synth/Synth.h +++ b/src/synth/Synth.h @@ -45,7 +45,7 @@ private: std::vector heldNotes_; // voices - static constexpr int MAX_VOICES = 12; + static constexpr int MAX_VOICES = 32; std::array voices_; uint32_t sampleRate_;