Move the voice selection after the polyphony checks

This commit is contained in:
Paul Ferrand 2020-08-25 19:12:03 +02:00
parent ed5fb61f38
commit ca7d74e841

View file

@ -932,16 +932,9 @@ void sfz::Synth::noteOnDispatch(int delay, int noteNumber, float velocity) noexc
if (region->registerNoteOn(noteNumber, velocity, randValue)) {
unsigned notePolyphonyCounter { 0 };
Voice* selfMaskCandidate { nullptr };
Voice* selectedVoice { nullptr };
regionPolyphonyArray.clear();
for (auto& voice : voices) {
if (voice->isFree()) {
if (selectedVoice == nullptr)
selectedVoice = voice.get();
continue;
}
if (voice->getRegion() == region && !voice->releasedOrFree()) {
regionPolyphonyArray.push_back(voice.get());
}
@ -1003,6 +996,8 @@ void sfz::Synth::noteOnDispatch(int delay, int noteNumber, float velocity) noexc
parent = parent->getParent();
}
Voice* selectedVoice = findFreeVoice();
// Engine polyphony reached, we're stealing something
if (selectedVoice == nullptr) {
selectedVoice = stealer.steal(absl::MakeSpan(voiceViewArray));