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_;