Set the threshold of ADSR release to -80 dB

This commit is contained in:
Jean Pierre Cimalando 2020-08-18 19:43:36 +02:00
parent 4c0a7f6dfd
commit 12e2c95f5c
2 changed files with 8 additions and 3 deletions

View file

@ -96,7 +96,7 @@ Type ADSREnvelope<Type>::getNextValue() noexcept
return currentValue;
case State::Release:
currentValue *= releaseRate;
if (currentValue > config::virtuallyZero)
if (currentValue > config::egReleaseThreshold)
return currentValue;
currentState = State::Done;
@ -169,9 +169,9 @@ void ADSREnvelope<Type>::getBlock(absl::Span<Type> output) noexcept
sfz::fill(output.first(count), currentValue);
break;
case State::Release:
while (count < size && (currentValue *= releaseRate) > config::virtuallyZero)
while (count < size && (currentValue *= releaseRate) > config::egReleaseThreshold)
output[count++] = currentValue;
if (currentValue <= config::virtuallyZero) {
if (currentValue <= config::egReleaseThreshold) {
currentValue = 0;
currentState = State::Done;
}

View file

@ -86,6 +86,11 @@ namespace config {
modulated filter. The lower, the more CPU resources are consumed.
*/
constexpr int filterControlInterval { 16 };
/**
Amplitude below which an exponential releasing envelope is considered as
finished.
*/
constexpr float egReleaseThreshold = 1e-4;
/**
Default metadata for MIDIName documents
*/