It is often necessary to map an audio parameter to a specific value range over a specific time duration. The most common example is to control the amplitude of a segment of an audio signal. For example, we typically want to smooth signal amplitudes over time, “ramping up” the gain of a chunk of sound when starting to listen to it and then “ramping down” the gain before we want to stop the sound. This is done to avoid discontinuities that might produce audible clicks or pops when being played through speakers. For this, we introduce the concept of time-dependent functions or envelopes that are typically designed to follow linear or exponential trajectories.
- A linear mapping over time can be determined from the equation for a line:
y(t) = m t + b
where m is the slope of the line and b is the point where the line crosses the vertical axis (t=0).
- The line slope is found as
.
- It is common to use a linear mapping in a real-time audio processing environment to scale a signal amplitude up from 0 to 1 or down from 1 to 0 over a specified time. Given that our sample rate is constant, the linear mapping can be applied simply by incrementing an ampltude value by a fixed value or rate (m Ts) at each time step:
y[n] = m Ts + y[n-1],
where Ts is the sampling period.
- Linear line segments can be concatenated over time to produce an envelope, as depicted in Fig. 2.
Figure 2:
A simple linear line segment envelope.
 |
- Exponential parameter decay and growth patterns are typically perceived as sounding more natural.
- One approach to mapping parameters with “exponential” curves is to make use of the equation:
y(t) = m tb,
where m is a scale factor calculated in a similar way to the linear line slope given above and b is a curvature constant greater than zero.
- Values of the curve parameter b less than 1.0 produce “logarithmic” growth and exponential decay patterns. Values of b greater than 1.0 produce exponential growth and logarithmic decay patterns. A value of b = 1.0 corresponds to linear growth and decay.
- Another approach to creating exponential curves is to use the general exponential function,
, remembering that exponential curves increase/decrease in equal proportion to their current value. This suggests an algorithm of the form:
where
, Ts is the sample period, and
is a user provided time constant.
- As with linear line segments, asymptotic segments can be concatenated over time to produce an envelope, as depicted in Fig. 3.
Figure 3:
A simple asymptotic line segment envelope.
 |
- Note that these curves never actually reach their target value (though a threshold value can be used, within which the current value is simply set equal to the target). This algorithm is especially convenient in situations where a specific time duration is not known.
- An ADSR envelope defines specific time and amplitude values for the “attack”, “decay”, “sustain”, and “release” portions of a sound event.
- In a realtime context, where event duration is unknown, the “sustain” duration can be undefined, with a “note off” event triggering the “release” portion.
- The strategies discussed above for linear and exponential envelopes can be directly applied to ADSR envelopes. The primary distinction becomes one of keeping track of the current "state" of the envelope.
Figure 4:
An ADSR envelope made with linear line segments.
 |
Figure 5:
An ADSR envelope made with asymptotic line segments.
 |
| ©2003-2026 McGill University. All Rights Reserved. Maintained by Gary P. Scavone.
|