Find a free voice on the fly
This commit is contained in:
parent
396fb2199a
commit
50ab6910e1
1 changed files with 13 additions and 14 deletions
|
|
@ -891,13 +891,16 @@ void sfz::Synth::noteOnDispatch(int delay, int noteNumber, float velocity) noexc
|
||||||
unsigned notePolyphonyCounter { 0 };
|
unsigned notePolyphonyCounter { 0 };
|
||||||
unsigned regionPolyphonyCounter { 0 };
|
unsigned regionPolyphonyCounter { 0 };
|
||||||
Voice* selfMaskCandidate { nullptr };
|
Voice* selfMaskCandidate { nullptr };
|
||||||
|
Voice* selectedVoice { nullptr };
|
||||||
|
|
||||||
for (auto& voice : voices) {
|
for (auto& voice : voices) {
|
||||||
const auto voiceRegion = voice->getRegion();
|
if (voice->isFree()) {
|
||||||
if (voiceRegion == nullptr)
|
if (selectedVoice == nullptr)
|
||||||
|
selectedVoice = voice.get();
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (voiceRegion == region)
|
if (voice->getRegion() == region)
|
||||||
regionPolyphonyCounter += 1;
|
regionPolyphonyCounter += 1;
|
||||||
|
|
||||||
if (region->notePolyphony) {
|
if (region->notePolyphony) {
|
||||||
|
|
@ -923,12 +926,12 @@ void sfz::Synth::noteOnDispatch(int delay, int noteNumber, float velocity) noexc
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Do something for the polyphony limit
|
// FIXME: Do something for the polyphony limit
|
||||||
if (polyphonyGroups[region->group].getActiveVoices().size()
|
if (regionPolyphonyCounter >= region->polyphony)
|
||||||
== polyphonyGroups[region->group].getPolyphonyLimit())
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// FIXME: Do something for the polyphony limit
|
// FIXME: Do something for the polyphony limit
|
||||||
if (regionPolyphonyCounter >= region->polyphony)
|
if (polyphonyGroups[region->group].getActiveVoices().size()
|
||||||
|
== polyphonyGroups[region->group].getPolyphonyLimit())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// FIXME: Do something for the polyphony limit
|
// FIXME: Do something for the polyphony limit
|
||||||
|
|
@ -952,14 +955,10 @@ void sfz::Synth::noteOnDispatch(int delay, int noteNumber, float velocity) noexc
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto voice = findFreeVoice();
|
selectedVoice->startVoice(region, delay, noteNumber, velocity, Voice::TriggerType::NoteOn);
|
||||||
if (voice == nullptr)
|
ring.addVoiceToRing(selectedVoice);
|
||||||
continue;
|
RegionSet::registerVoiceInHierarchy(region, selectedVoice);
|
||||||
|
polyphonyGroups[region->group].registerVoice(selectedVoice);
|
||||||
voice->startVoice(region, delay, noteNumber, velocity, Voice::TriggerType::NoteOn);
|
|
||||||
ring.addVoiceToRing(voice);
|
|
||||||
RegionSet::registerVoiceInHierarchy(region, voice);
|
|
||||||
polyphonyGroups[region->group].registerVoice(voice);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue