- A linear mapping of parameters 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 by
.
- In a system such as Matlab, we can plot this expression as
*y*(*t*) =*m*(*t*-*t*_{0}) +*y*_{0}, where*t*_{0}is the initial time value and*y*_{0}is the value of*y*at*t*_{0}. - In an audio processing system, our sample rate is constant and this allows us to simply increment our parameter value by a fixed rate (i.e. slope) value at each time step:

*y*[*n*] =*m T*_{s}+*y*[*n*-1],

where*T*_{s}is the sampling period. - A C language implementation is shown below for each time step:
if ( state != 0 ) { if (target > value) { value += rate; if (value >= target) { value = target; state = 0; } } else { value -= rate; if (value <= target) { value = target; state = 0; } } } return value;

- 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 t*^{b},

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. - The Matlab script
`curve.m`demonstrates the use of the above equation for generating exponential envelopes. - Another approach to exponential envelopes 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 ,*T*is the sample period, and is a user provided time constant. - The Matlab script
`asymp.m`demonstrates the use of this last equation for generating exponential envelopes. - 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.
- 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.

©2004-2019 McGill University. All Rights Reserved. Maintained by Gary P. Scavone. |