clipping fix

This commit is contained in:
2026-01-14 21:11:23 -06:00
parent 5661e4662c
commit cff31af328
2 changed files with 3 additions and 1 deletions

View File

@@ -92,6 +92,8 @@ void Synth::process(float* out, uint32_t nFrames, uint32_t sampleRate) {
for(Voice& v : voices_) { for(Voice& v : voices_) {
mix += v.process(params, triggered); mix += v.process(params, triggered);
} }
mix /= 4.0f; // for number of voices to prevent clipping
mix = tanh(mix); // really prevents clipping
sampleOut = mix; sampleOut = mix;

View File

@@ -45,7 +45,7 @@ private:
std::vector<uint8_t> heldNotes_; std::vector<uint8_t> heldNotes_;
// voices // voices
static constexpr int MAX_VOICES = 12; static constexpr int MAX_VOICES = 32;
std::array<Voice, MAX_VOICES> voices_; std::array<Voice, MAX_VOICES> voices_;
uint32_t sampleRate_; uint32_t sampleRate_;