From 4d87716a305e39723836553a81efade0b1d64e93 Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Wed, 16 Sep 2020 08:41:02 +0200 Subject: [PATCH] Offset the time so that the envelopes "end" on the correct value The envelope start is always considered to be the value before the current ramp started --- src/sfizz/FlexEnvelope.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sfizz/FlexEnvelope.cpp b/src/sfizz/FlexEnvelope.cpp index 321093fc..d56aad25 100644 --- a/src/sfizz/FlexEnvelope.cpp +++ b/src/sfizz/FlexEnvelope.cpp @@ -165,11 +165,11 @@ void FlexEnvelope::Impl::process(absl::Span out) const Curve& curve = *stageCurve_; size_t framesDone = 0; while ((time < stageEndTime || sustained) && frameIndex < maxFrameIndex) { + time += samplePeriod; float x = time * (1.0f / stageEndTime); float c = curve.evalNormalized(x); level = sourceLevel + c * (targetLevel - sourceLevel); out[frameIndex++] = level; - time += samplePeriod; ++framesDone; } currentLevel_ = level;