diff --git a/src/sfizz/Synth.cpp b/src/sfizz/Synth.cpp index 40dd331b..dcbffc6f 100644 --- a/src/sfizz/Synth.cpp +++ b/src/sfizz/Synth.cpp @@ -1062,10 +1062,8 @@ void sfz::Synth::hdcc(int delay, int ccNumber, float normValue) noexcept return matchReleaseRegionAndVoice(*region, *v); }; - if (absl::c_find_if(voices, compatibleVoice) == voices.end()) { + if (absl::c_find_if(voices, compatibleVoice) == voices.end()) region->delayedReleases.clear(); - continue; - } } for (auto& note: region->delayedReleases) { @@ -1082,7 +1080,9 @@ void sfz::Synth::hdcc(int delay, int ccNumber, float normValue) noexcept } region->delayedReleases.clear(); - } else if (region->registerCC(ccNumber, normValue)) { + } + + if (region->registerCC(ccNumber, normValue)) { auto voice = findFreeVoice(); if (voice == nullptr) continue; diff --git a/tests/SynthT.cpp b/tests/SynthT.cpp index 8f0e94a5..cf933ead 100644 --- a/tests/SynthT.cpp +++ b/tests/SynthT.cpp @@ -1120,3 +1120,26 @@ TEST_CASE("[Synth] Used CCs EGs") // REQUIRE( usedCCs[27] ); // REQUIRE( !usedCCs[28] ); } + +TEST_CASE("[Synth] Activate also on the sustain CC") +{ + sfz::Synth synth; + synth.loadSfzString(fs::current_path(), R"( + locc64=64 key=53 sample=*sine + )"); + synth.noteOn(0, 53, 127); + REQUIRE( synth.getNumActiveVoices(true) == 0 ); + synth.cc(1, 64, 127); + synth.noteOn(2, 53, 127); + REQUIRE( synth.getNumActiveVoices(true) == 1 ); +} + +TEST_CASE("[Synth] Trigger also on the sustain CC") +{ + sfz::Synth synth; + synth.loadSfzString(fs::current_path(), R"( + on_locc64=64 sample=*sine + )"); + synth.cc(0, 64, 127); + REQUIRE( synth.getNumActiveVoices(true) == 1 ); +}