Merge pull request #413 from paulfd/choking-across-cc-switches

Regions on the same note but with different groups do get muted
This commit is contained in:
JP Cimalando 2020-09-10 08:06:25 +02:00 committed by GitHub
commit ed6c9557f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 2 deletions

View file

@ -713,9 +713,9 @@ bool sfz::Voice::checkOffGroup(const Region* other, int delay, int noteNumber) n
if (region == nullptr || other == nullptr)
return false;
if (triggerEvent.type == TriggerEventType::NoteOn
if (triggerEvent.type == TriggerEventType::NoteOn
&& region->offBy == other->group
&& noteNumber != triggerEvent.number) {
&& (region->group != other->group || noteNumber != triggerEvent.number)) {
off(delay);
return true;
}

View file

@ -1324,3 +1324,27 @@ TEST_CASE("[Synth] Off by same note and group")
REQUIRE( numPlayingVoices(synth) == 2 );
synth.noteOn(0, 60, 85);
}
TEST_CASE("[Synth] Off by with CC switches")
{
sfz::Synth synth;
sfz::AudioBuffer<float> buffer { 2, 256 };
synth.loadSfzString(fs::current_path(), R"(
<group> ampeg_decay=5 ampeg_sustain=0 ampeg_release=5 key=60
<region> sample=*saw transpose=12 group=1 off_by=2 hicc4=63
<region> sample=*triangle group=2 off_by=1 locc4=64
)");
synth.noteOn(0, 60, 85);
REQUIRE( numPlayingVoices(synth) == 1 );
REQUIRE( getPlayingVoices(synth).front()->getRegion()->sampleId.filename() == "*saw" );
synth.cc(0, 4, 127);
synth.noteOn(0, 60, 85);
REQUIRE( numPlayingVoices(synth) == 1 );
REQUIRE( getPlayingVoices(synth).front()->getRegion()->sampleId.filename() == "*triangle" );
synth.cc(0, 4, 0);
synth.noteOn(0, 60, 85);
REQUIRE( numPlayingVoices(synth) == 1 );
REQUIRE( getPlayingVoices(synth).front()->getRegion()->sampleId.filename() == "*saw" );
}