Make the matching function a free one
This commit is contained in:
parent
39abff2cca
commit
cb367d385f
1 changed files with 11 additions and 12 deletions
|
|
@ -837,6 +837,15 @@ void sfz::Synth::noteOff(int delay, int noteNumber, uint8_t velocity) noexcept
|
||||||
noteOffDispatch(delay, noteNumber, replacedVelocity);
|
noteOffDispatch(delay, noteNumber, replacedVelocity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool matchReleaseRegionAndVoice(const sfz::Region& region, const sfz::Voice& voice) {
|
||||||
|
return (
|
||||||
|
!voice.isFree()
|
||||||
|
&& voice.getTriggerType() == sfz::Voice::TriggerType::NoteOn
|
||||||
|
&& region.keyRange.containsWithEnd(voice.getTriggerNumber())
|
||||||
|
&& region.velocityRange.containsWithEnd(voice.getTriggerValue())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void sfz::Synth::noteOffDispatch(int delay, int noteNumber, float velocity) noexcept
|
void sfz::Synth::noteOffDispatch(int delay, int noteNumber, float velocity) noexcept
|
||||||
{
|
{
|
||||||
const auto randValue = randNoteDistribution(Random::randomGenerator);
|
const auto randValue = randNoteDistribution(Random::randomGenerator);
|
||||||
|
|
@ -851,12 +860,7 @@ void sfz::Synth::noteOffDispatch(int delay, int noteNumber, float velocity) noex
|
||||||
// should be overhauled, also to include voice stealing on
|
// should be overhauled, also to include voice stealing on
|
||||||
// all events
|
// all events
|
||||||
const auto compatibleVoice = [region](const VoicePtr& v) -> bool {
|
const auto compatibleVoice = [region](const VoicePtr& v) -> bool {
|
||||||
return (
|
return matchReleaseRegionAndVoice(*region, *v);
|
||||||
!v->isFree()
|
|
||||||
&& v->getTriggerType() == Voice::TriggerType::NoteOn
|
|
||||||
&& region->keyRange.containsWithEnd(v->getTriggerNumber())
|
|
||||||
&& region->velocityRange.containsWithEnd(v->getTriggerValue())
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (absl::c_find_if(voices, compatibleVoice) == voices.end())
|
if (absl::c_find_if(voices, compatibleVoice) == voices.end())
|
||||||
|
|
@ -1028,12 +1032,7 @@ void sfz::Synth::hdcc(int delay, int ccNumber, float normValue) noexcept
|
||||||
// should be overhauled, also to include voice stealing on
|
// should be overhauled, also to include voice stealing on
|
||||||
// all events
|
// all events
|
||||||
const auto compatibleVoice = [region](const VoicePtr& v) -> bool {
|
const auto compatibleVoice = [region](const VoicePtr& v) -> bool {
|
||||||
return (
|
return matchReleaseRegionAndVoice(*region, *v);
|
||||||
!v->isFree()
|
|
||||||
&& v->getTriggerType() == Voice::TriggerType::NoteOn
|
|
||||||
&& region->keyRange.containsWithEnd(v->getTriggerNumber())
|
|
||||||
&& region->velocityRange.containsWithEnd(v->getTriggerValue())
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (absl::c_find_if(voices, compatibleVoice) == voices.end()) {
|
if (absl::c_find_if(voices, compatibleVoice) == voices.end()) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue