Add special cases for the rate transformation in envelopes
For increasing linear ramps, a 0s ramp is an increment of 1.0 For decaying exponential ramps, a 0s ramp is a multiplicator of 0.0f
This commit is contained in:
parent
fae0cda971
commit
f6e0bb8b3f
1 changed files with 6 additions and 1 deletions
|
|
@ -20,13 +20,18 @@ Type ADSREnvelope<Type>::secondsToSamples (Type timeInSeconds) const noexcept
|
|||
template<class Type>
|
||||
Type ADSREnvelope<Type>::secondsToLinRate (Type timeInSeconds) const noexcept
|
||||
{
|
||||
timeInSeconds = std::max<Type>(timeInSeconds, config::virtuallyZero);
|
||||
if (timeInSeconds == 0)
|
||||
return 1.0f;
|
||||
|
||||
return 1 / (sampleRate * timeInSeconds);
|
||||
};
|
||||
|
||||
template<class Type>
|
||||
Type ADSREnvelope<Type>::secondsToExpRate (Type timeInSeconds) const noexcept
|
||||
{
|
||||
if (timeInSeconds == 0)
|
||||
return 0.0f;
|
||||
|
||||
timeInSeconds = std::max<Type>(25e-3, timeInSeconds);
|
||||
return std::exp(-9.0 / (timeInSeconds * sampleRate));
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue