commit 9967063b039ef288b8df433ef853b92cdc14baa9
parent d6a8c142d0c9c3fe2493ec1b0416b7c9d8ad7cc8
Author: Matt Demanett <matt@demanett.net>
Date: Fri, 13 Mar 2020 14:49:28 -0400
Fix problem with ADSR dsp where abrupt parameter changes could produce very large outputs (fixed). #103
Diffstat:
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/dsp/envelope.cpp b/src/dsp/envelope.cpp
@@ -125,13 +125,13 @@ float ADSR::_next() {
}
case ATTACK_STAGE: {
_stageProgress += _sampleTime;
- _envelope = std::max(1.0f, _stageProgress / _attack);
+ _envelope = std::min(1.0f, _stageProgress / _attack);
_envelope = powf(_envelope, _attackShape);
break;
}
case DECAY_STAGE: {
_stageProgress += _sampleTime;
- _envelope = std::max(1.0f, _stageProgress / _decay);
+ _envelope = std::min(1.0f, _stageProgress / _decay);
_envelope = powf(_envelope, _decayShape);
_envelope *= 1.0f - _sustain;
_envelope = 1.0f - _envelope;
@@ -143,7 +143,7 @@ float ADSR::_next() {
}
case RELEASE_STAGE: {
_stageProgress += _sampleTime;
- _envelope = std::max(1.0f, _stageProgress / _release);
+ _envelope = std::min(1.0f, _stageProgress / _release);
_envelope = powf(_envelope, _releaseShape);
_envelope *= _releaseLevel;
_envelope = _releaseLevel - _envelope;