Don't release age 0 voices

This commit is contained in:
Paul Ferrand 2020-08-25 23:23:14 +02:00
parent 6750fb93a2
commit 1f65c135bc
2 changed files with 8 additions and 2 deletions

View file

@ -665,6 +665,11 @@ sfz::Voice* sfz::Synth::findFreeVoice() noexcept
if (stolenVoice == nullptr)
return {};
// Never kill age 0 voices
if (stolenVoice->getAge() == 0)
return {};
auto tempSpan = resources.bufferPool.getStereoBuffer(samplesPerBlock);
SisterVoiceRing::applyToRing(stolenVoice, [&] (Voice* v) {
renderVoiceToOutputs(*v, *tempSpan);
@ -991,8 +996,9 @@ void sfz::Synth::checkNotePolyphony(const Region* region, int delay, const Trigg
}
}
if (notePolyphonyCounter >= *region->notePolyphony && selfMaskCandidate)
if (notePolyphonyCounter >= *region->notePolyphony && selfMaskCandidate) {
SisterVoiceRing::offAllSisters(selfMaskCandidate, delay);
}
}
void sfz::Synth::checkGroupPolyphony(const Region* region, int delay) noexcept

View file

@ -25,7 +25,7 @@ sfz::Voice* sfz::VoiceStealing::steal(absl::Span<sfz::Voice*> voices) noexcept
// their sound, but it's reasonable for sounds with a quick attack and longer
// release.
const auto ageThreshold =
static_cast<int>(voices.front()->getAge() * config::stealingAgeCoeff) + 1;
static_cast<int>(voices.front()->getAge() * config::stealingAgeCoeff);
Voice* returnedVoice = voices.front();
unsigned idx = 0;