Merge pull request #972 from praashie/fix-off-group

Fix `off_by` behavior with long-releasing notes
This commit is contained in:
Paul Ferrand 2021-09-22 07:10:51 +02:00 committed by GitHub
commit e8f796156f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View file

@ -1666,7 +1666,7 @@ bool Voice::checkOffGroup(const Region* other, int delay, int noteNumber) noexce
if (region == nullptr || other == nullptr)
return false;
if (impl.released())
if (impl.offed_)
return false;
if ((impl.triggerEvent_.type == TriggerEventType::NoteOn

View file

@ -1568,6 +1568,26 @@ TEST_CASE("[Synth] Off by alone and repeated")
REQUIRE( numPlayingVoices(synth) == 3 );
}
TEST_CASE("[Synth] Off by with staccato notes")
{
sfz::Synth synth;
sfz::AudioBuffer<float> buffer { 2, static_cast<unsigned>(synth.getSamplesPerBlock()) };
synth.loadSfzString(fs::current_path(), R"(
<region> group=1 off_by=1 sample=*sine ampeg_release=2
)");
synth.noteOn(0, 60, 85);
synth.renderBlock(buffer);
REQUIRE( numPlayingVoices(synth) == 1 );
synth.noteOff(0, 60, 85);
synth.renderBlock(buffer);
REQUIRE( numPlayingVoices(synth) == 0 );
REQUIRE( numActiveVoices(synth) == 1 );
synth.noteOn(0, 62, 85);
synth.renderBlock(buffer);
REQUIRE( numActiveVoices(synth) == 1 );
}
TEST_CASE("[Synth] Off by same note and group")
{