Skip to content

Commit 694abb2

Browse files
* Fixed release getting cut off if the decay time was zero
- This was a bug in the ADSR envelope update
1 parent 979df38 commit 694abb2

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Diff for: Envelope.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,16 @@ float EnvelopeState::Update(EnvelopeConfig const &config, float const step)
9696

9797
case RELEASE:
9898
env_target = ENV_DECAY_BIAS;
99-
if (amplitude < config.sustain_level || config.decay_rate < config.release_rate)
99+
if (amplitude <= config.sustain_level || config.decay_rate < config.release_rate)
100+
{
100101
amplitude += (env_target - amplitude) * config.release_rate * step;
102+
}
101103
else
104+
{
102105
amplitude += (env_target - amplitude) * config.decay_rate * step;
106+
if (amplitude <= config.sustain_level)
107+
amplitude = config.sustain_level;
108+
}
103109
if (amplitude <= 0.0f)
104110
{
105111
amplitude = 0.0f;

0 commit comments

Comments
 (0)