Merge pull request #998 from paulfd/no-off-trigger-on-cc-triggers

Don't dispatch off notes when offing a CC-trig'd voice
This commit is contained in:
Paul Ferrand 2021-10-20 20:48:52 +02:00 committed by GitHub
commit 95062c1611
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 2 deletions

View file

@ -1164,7 +1164,8 @@ void Synth::Impl::checkOffGroups(const Region* region, int delay, int number)
for (auto& voice : voiceManager_) {
if (voice.checkOffGroup(region, delay, number)) {
const TriggerEvent& event = voice.getTriggerEvent();
noteOffDispatch(delay, event.number, event.value);
if (event.type == TriggerEventType::NoteOn)
noteOffDispatch(delay, event.number, event.value);
}
}
}

View file

@ -390,7 +390,6 @@ TEST_CASE("[Triggers] sw_vel, consider the previous velocity for triggers")
}
}
TEST_CASE("[Triggers] Honor lorand/hirand on CC triggers")
{
Synth synth;
@ -408,3 +407,22 @@ TEST_CASE("[Triggers] Honor lorand/hirand on CC triggers")
synth.hdcc(0, 64, 100_norm);
REQUIRE(numPlayingVoices(synth) == 1);
}
TEST_CASE("[Triggers] Offed voices with CC triggers do not activate release triggers")
{
Synth synth;
sfz::AudioBuffer<float> buffer { 2, static_cast<unsigned>(synth.getSamplesPerBlock()) };
std::vector<std::string> messageList;
Client client(&messageList);
client.setReceiveCallback(&simpleMessageReceiver);
synth.loadSfzString(fs::current_path() / "tests/TestFiles/sw_vel.sfz", R"(
<region> sample=*sine hikey=-1 start_locc64=63 start_hicc64=127 group=1 off_by=2
<region> sample=*saw hikey=-1 start_locc64=0 start_hicc64=62 group=2
<region> sample=*noise trigger=release_key
)");
synth.hdcc(0, 64, 100_norm);
REQUIRE(playingSamples(synth) == std::vector<std::string> { "*sine" });
synth.hdcc(10, 64, 10_norm);
REQUIRE(playingSamples(synth) == std::vector<std::string> { "*saw" });
}