Skip to content

Commit

Permalink
Merge pull request #723 from paulfd/neverending-eg
Browse files Browse the repository at this point in the history
Free-run the envelope if the sustain value is low enough
  • Loading branch information
jpcima authored Mar 19, 2021
2 parents d183c8c + 287832e commit 39816ca
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/sfizz/ADSREnvelope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions src/sfizz/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 39816ca

Please sign in to comment.