Don't dispatch off notes when offing a CC-trig'd voice

Check behavior
This commit is contained in:
Paul Fd 2021-10-20 17:09:16 +02:00
parent 213647d154
commit cba1f8a86a
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_) { for (auto& voice : voiceManager_) {
if (voice.checkOffGroup(region, delay, number)) { if (voice.checkOffGroup(region, delay, number)) {
const TriggerEvent& event = voice.getTriggerEvent(); 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") TEST_CASE("[Triggers] Honor lorand/hirand on CC triggers")
{ {
Synth synth; Synth synth;
@ -408,3 +407,22 @@ TEST_CASE("[Triggers] Honor lorand/hirand on CC triggers")
synth.hdcc(0, 64, 100_norm); synth.hdcc(0, 64, 100_norm);
REQUIRE(numPlayingVoices(synth) == 1); 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" });
}