From 342cd99dd9eec2cab8f750db23f32f77492177df Mon Sep 17 00:00:00 2001 From: KIRA Ryouta Date: Sat, 24 Feb 2024 00:09:51 +0900 Subject: [PATCH] Fix to pass a Polyphony test. --- src/sfizz/ADSREnvelope.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/sfizz/ADSREnvelope.cpp b/src/sfizz/ADSREnvelope.cpp index fa952373c..b6080fca6 100644 --- a/src/sfizz/ADSREnvelope.cpp +++ b/src/sfizz/ADSREnvelope.cpp @@ -102,9 +102,17 @@ void ADSREnvelope::getBlockInternal(absl::Span output) noexcept // prevent computing the segment further than release point size = std::min(size, releaseDelay); } else if (releaseDelay == 0 && delay <= 0) { + if (delay < 0) { + // release takes effect this frame + currentState = State::Release; + } else { + // release takes effect the next frame + size = 1; + } + releaseDelay = -1; + } else if (releaseDelay == -1 && currentState < State::Release && delay <= 0) { // release takes effect this frame currentState = State::Release; - releaseDelay = -1; } }