From bf5f4a7994756c099c353623053de0c8f1fb2413 Mon Sep 17 00:00:00 2001 From: Oskar Wallgren Date: Fri, 13 Oct 2023 22:34:41 +0000 Subject: [PATCH] Fix instrument release being applied early As discovered by @michaelgregorious & @zonkmachine, applyRelease's condition to determine whether the release ramp starts within the current buffer was off by 1 frame, running the release code when the ramp should only start in frame 0 of the next buffer. This could cause the ramp to be miscalculated, starting at a value greater than 1.0 and and thus actually amplifying the signal. --- src/core/Instrument.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/Instrument.cpp b/src/core/Instrument.cpp index fd729e3ab..2f987aaed 100644 --- a/src/core/Instrument.cpp +++ b/src/core/Instrument.cpp @@ -182,7 +182,7 @@ void Instrument::applyRelease( sampleFrame * buf, const NotePlayHandle * _n ) const fpp_t frames = _n->framesLeftForCurrentPeriod(); const fpp_t fpp = Engine::audioEngine()->framesPerPeriod(); const f_cnt_t fl = _n->framesLeft(); - if( fl <= desiredReleaseFrames()+fpp ) + if( fl < desiredReleaseFrames()+fpp ) { for( fpp_t f = (fpp_t)( ( fl > desiredReleaseFrames() ) ? (std::max(fpp - desiredReleaseFrames(), 0) +