Merge pull request #376 from jpcima/adsr-rate
Adjust the ADSR exponential rate
This commit is contained in:
commit
be7ff64a17
2 changed files with 9 additions and 4 deletions
|
|
@ -28,7 +28,7 @@ template<class Type>
|
|||
Type ADSREnvelope<Type>::secondsToExpRate (Type timeInSeconds) const noexcept
|
||||
{
|
||||
timeInSeconds = std::max<Type>(25e-3, timeInSeconds);
|
||||
return std::exp(-8.0 / (timeInSeconds * sampleRate));
|
||||
return std::exp(-9.0 / (timeInSeconds * sampleRate));
|
||||
};
|
||||
|
||||
template <class Type>
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue