Proper behavior when sustain = 0
This commit is contained in:
parent
8dc532b58d
commit
f9763c0058
1 changed files with 10 additions and 4 deletions
|
|
@ -58,7 +58,10 @@ Type ADSREnvelope<Type>::getNextValue() noexcept
|
||||||
{
|
{
|
||||||
if (shouldRelease && releaseDelay-- == 0) {
|
if (shouldRelease && releaseDelay-- == 0) {
|
||||||
currentState = State::Release;
|
currentState = State::Release;
|
||||||
step = std::exp((std::log(config::virtuallyZero) - std::log(currentValue)) / (release > 0 ? release : 1));
|
if (currentValue > config::virtuallyZero)
|
||||||
|
step = std::exp((std::log(config::virtuallyZero) - std::log(currentValue + config::virtuallyZero)) / (release > 0 ? release : 1));
|
||||||
|
else
|
||||||
|
step = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (currentState) {
|
switch (currentState) {
|
||||||
|
|
@ -82,7 +85,7 @@ Type ADSREnvelope<Type>::getNextValue() noexcept
|
||||||
if (hold-- > 0)
|
if (hold-- > 0)
|
||||||
return currentValue;
|
return currentValue;
|
||||||
|
|
||||||
step = std::exp(std::log(sustain) / (decay > 0 ? decay : 1));
|
step = std::exp(std::log(sustain + config::virtuallyZero) / (decay > 0 ? decay : 1));
|
||||||
currentState = State::Decay;
|
currentState = State::Decay;
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
case State::Decay:
|
case State::Decay:
|
||||||
|
|
@ -150,7 +153,7 @@ void ADSREnvelope<Type>::getBlock(absl::Span<Type> output) noexcept
|
||||||
if (remainingSamples == 0)
|
if (remainingSamples == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
step = std::exp(std::log(sustain) / (decay > 0 ? decay : 1));
|
step = std::exp(std::log(sustain + config::virtuallyZero) / (decay > 0 ? decay : 1));
|
||||||
currentState = State::Decay;
|
currentState = State::Decay;
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
case State::Decay:
|
case State::Decay:
|
||||||
|
|
@ -196,7 +199,10 @@ void ADSREnvelope<Type>::getBlock(absl::Span<Type> output) noexcept
|
||||||
originalSpan.remove_prefix(releaseDelay);
|
originalSpan.remove_prefix(releaseDelay);
|
||||||
if (originalSpan.size() > 0)
|
if (originalSpan.size() > 0)
|
||||||
currentValue = originalSpan.front();
|
currentValue = originalSpan.front();
|
||||||
|
if (currentValue > config::virtuallyZero)
|
||||||
step = std::exp((std::log(config::virtuallyZero) - std::log(currentValue)) / (release > 0 ? release : 1));
|
step = std::exp((std::log(config::virtuallyZero) - std::log(currentValue)) / (release > 0 ? release : 1));
|
||||||
|
else
|
||||||
|
step = 1;
|
||||||
remainingSamples -= releaseDelay;
|
remainingSamples -= releaseDelay;
|
||||||
length = min(remainingSamples, release);
|
length = min(remainingSamples, release);
|
||||||
currentState = State::Release;
|
currentState = State::Release;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue