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
This commit is contained in:
Paul Ferrand 2020-09-16 08:41:02 +02:00
parent 19540e821a
commit 4d87716a30

View file

@ -165,11 +165,11 @@ void FlexEnvelope::Impl::process(absl::Span<float> 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;