Corrected a bug in the release logic
The correct check was that the remaining delay is strictly more than 0, and added a max for good measure.
This commit is contained in:
parent
ca7c4f2939
commit
d6c49ef827
3 changed files with 18 additions and 2 deletions
|
|
@ -135,7 +135,7 @@ void sfz::Voice::release(int delay, bool fastRelease) noexcept
|
||||||
if (state != State::playing)
|
if (state != State::playing)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (egEnvelope.getRemainingDelay() >= (delay - initialDelay)) {
|
if (egEnvelope.getRemainingDelay() > std::max(0, delay - initialDelay)) {
|
||||||
reset();
|
reset();
|
||||||
} else {
|
} else {
|
||||||
state = State::release;
|
state = State::release;
|
||||||
|
|
|
||||||
|
|
@ -220,3 +220,19 @@ TEST_CASE("[Synth] Releasing before the EG started smoothing (initial delay) kil
|
||||||
synth.noteOff(1000, 1, 60, 63);
|
synth.noteOff(1000, 1, 60, 63);
|
||||||
REQUIRE( !synth.getVoiceView(0)->isFree() );
|
REQUIRE( !synth.getVoiceView(0)->isFree() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("[Synth] Releasing after the initial and normal mode does not trigger a fast release")
|
||||||
|
{
|
||||||
|
sfz::Synth synth;
|
||||||
|
synth.setSamplesPerBlock(1024);
|
||||||
|
sfz::AudioBuffer<float> buffer(2, 1024);
|
||||||
|
synth.setNumVoices(1);
|
||||||
|
synth.loadSfzFile(fs::current_path() / "tests/TestFiles/delay_release.sfz");
|
||||||
|
synth.noteOn(200, 1, 60, 63);
|
||||||
|
REQUIRE( !synth.getVoiceView(0)->isFree() );
|
||||||
|
synth.renderBlock(buffer);
|
||||||
|
REQUIRE( !synth.getVoiceView(0)->isFree() );
|
||||||
|
synth.noteOff(0, 1, 60, 63);
|
||||||
|
synth.renderBlock(buffer);
|
||||||
|
REQUIRE( !synth.getVoiceView(0)->isFree() );
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
<region> delay=0.005 sample=dummy1.wav
|
<region> ampeg_delay=0.005 ampeg_release=1 sample=dummy1.wav
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue