flexEG: allow release to bypass the pre-sustain stages

It makes the EG equivalent to ARIA in case of early release.
This commit is contained in:
Jean Pierre Cimalando 2020-09-28 21:49:20 +02:00
parent 1afc987794
commit 9d0ee6969c

View file

@ -160,12 +160,24 @@ void FlexEnvelope::Impl::process(absl::Span<float> out)
}
// Perform stage transitions
const bool isReleased = isReleased_;
while ((!stageSustained_ && currentTime_ >= stageTime_) ||
(stageSustained_ && isReleased)) {
// If stage is of zero duration, immediate transition to level
if (!stageSustained_ && stageTime_ == 0)
if (isReleased_) {
// on release, fast forward past the sustain stage
const unsigned sustainStage = desc.sustain;
while (currentStageNumber_ <= sustainStage) {
if (!advanceToNextStage()) {
out.remove_prefix(frameIndex);
fill(out, 0.0f);
return;
}
}
}
while (!stageSustained_ && currentTime_ >= stageTime_) {
// advance through completed timed stages
ASSERT(isReleased_ || !stageSustained_);
if (stageTime_ == 0) {
// if stage is of zero duration, immediate transition to level
currentLevel_ = stageTargetLevel_;
}
if (!advanceToNextStage()) {
out.remove_prefix(frameIndex);
fill(out, 0.0f);