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.
if ( atTarget == false ) { if (target > value) { value += rate; if (value >= target) { value = target; atTarget = true; } } else { value -= rate; if (value <= target) { value = target; atTarget = true; } } } return value;
![]() | ©2004-2025 McGill University. All Rights Reserved. Maintained by Gary P. Scavone. |