From f5aa3c7b9c57ed249f3d108ade016978351777de Mon Sep 17 00:00:00 2001 From: Jean Pierre Cimalando Date: Tue, 2 Feb 2021 17:15:24 +0100 Subject: [PATCH] Do not count overflow voices which are over limit --- src/sfizz/Synth.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/sfizz/Synth.cpp b/src/sfizz/Synth.cpp index 2a12f683..93617268 100644 --- a/src/sfizz/Synth.cpp +++ b/src/sfizz/Synth.cpp @@ -794,7 +794,15 @@ void Synth::loadStretchTuningByRatio(float ratio) int Synth::getNumActiveVoices() const noexcept { Impl& impl = *impl_; - return static_cast(impl.voiceManager_.getNumActiveVoices()); + + int activeVoices = static_cast(impl.voiceManager_.getNumActiveVoices()); + + // do not count overflow voices which are over limit + int resultVoices = activeVoices; + if (config::overflowVoiceMultiplier > 1) + resultVoices = std::min(impl.numVoices_, activeVoices); + + return resultVoices; } void Synth::setSamplesPerBlock(int samplesPerBlock) noexcept