From cba1f8a86a566e2454b15747f34effe466930b85 Mon Sep 17 00:00:00 2001 From: Paul Fd Date: Wed, 20 Oct 2021 17:09:16 +0200 Subject: [PATCH] Don't dispatch off notes when offing a CC-trig'd voice Check behavior --- src/sfizz/Synth.cpp | 3 ++- tests/RegionTriggersT.cpp | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/sfizz/Synth.cpp b/src/sfizz/Synth.cpp index 049af524..fbf5f158 100644 --- a/src/sfizz/Synth.cpp +++ b/src/sfizz/Synth.cpp @@ -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); } } } diff --git a/tests/RegionTriggersT.cpp b/tests/RegionTriggersT.cpp index 039fe4bb..b2548683 100644 --- a/tests/RegionTriggersT.cpp +++ b/tests/RegionTriggersT.cpp @@ -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 buffer { 2, static_cast(synth.getSamplesPerBlock()) }; + std::vector messageList; + Client client(&messageList); + client.setReceiveCallback(&simpleMessageReceiver); + synth.loadSfzString(fs::current_path() / "tests/TestFiles/sw_vel.sfz", R"( + sample=*sine hikey=-1 start_locc64=63 start_hicc64=127 group=1 off_by=2 + sample=*saw hikey=-1 start_locc64=0 start_hicc64=62 group=2 + sample=*noise trigger=release_key + )"); + + synth.hdcc(0, 64, 100_norm); + REQUIRE(playingSamples(synth) == std::vector { "*sine" }); + synth.hdcc(10, 64, 10_norm); + REQUIRE(playingSamples(synth) == std::vector { "*saw" }); +}