An integrating filter like Decay, but both the onset time and decay time can be specified.
Decay2.ar(in, attackTime, decayTime)
is equivalent to:
Decay.ar(in, decayTime) - Decay.ar(in, attackTime)
For precise control over the attack, decay, and level of Decay2
see Onset control and normalizing the envelope of Decay2 and Calculating rise time and maximum rise time of Decay2 below.
in |
The input signal. |
attackTime |
60 dB attack time in seconds. |
decayTime |
60 dB decay time in seconds. |
mul |
The output will be multiplied by this value. |
add |
This value will be added to the output. |
Since Decay2
is equivalent to the difference of two Decays, swapping the attackTime and decayTime inverts the envelope:
It can be useful to parameterize Decay2
so that its peak value is 1.0
, and to be able to control when the peak value is reached. The following example normalizes the envelope of Decay2
and provides a parameter, riseScale
, to shift the onset earlier or later.
A riseScale
value of 0.0
gives a sharp onset time of just one sample, making it nearly equivalent to Decay. A value of just less than 1.0
(it cannot be equal to 1.0
) will generate the latest possible onset time, which is ~15% of the decayTime.
In the previous example, note that t60
is "approximate" because, while the rate of decay converges to that of the corresponding decay time, the actual time when the impulse response decays to -60 dB will be delayed as riseScale
increases. This is apparent when looking at the impulse response on a decibel scale, with increasing values for riseScale
.
The longest possible rise time is constrained to ~15% of the decayTime. This maximum rise time, as well as exact rise time for a given riseScale
factor, can be calculated as follows: