Merge pull request #723 from paulfd/neverending-eg

Free-run the envelope if the sustain value is low enough
This commit is contained in:
JP Cimalando 2021-03-20 00:28:41 +01:00 committed by GitHub
commit 39816ca8d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -52,7 +52,7 @@ void ADSREnvelope::reset(const EGDescription& desc, const Region& region, const
sustainThreshold = this->sustain + config::virtuallyZero;
shouldRelease = false;
freeRunning = (
(this->sustain == Float(0.0))
(this->sustain <= Float(config::sustainFreeRunningThreshold))
|| (region.loopMode == LoopMode::one_shot && region.isOscillator())
);
currentValue = this->start;

View file

@ -167,6 +167,11 @@ namespace config {
* @brief The smoothing time constant per "smooth" steps
*/
constexpr float smoothTauPerStep { 3e-3 };
/**
* @brief If a value below this threshold is given to `ampeg_sustain`, the envelope will free-run
* and the voice will release itself at the end of the decay stage.
*/
constexpr float sustainFreeRunningThreshold { 0.0032f };
} // namespace config
} // namespace sfz