Simple envelope follower

An "envelope follower" provides a smoothed global representation of the extreme amplitudes of a signal. It can be as rough or as detailed as you want it to be, depending on how much of the original signal you disregard in the evaluation of the peaks. Because sound signals tend to vary in both positive and negative directions around a central 0 value, it's best to evaluate the absolute values of the samples, so that peaks in the negative direction are easily compared to peaks in the positive direction.

Creating a window on a sound file

A "window" is a function (shape) used to control the amplitude of a sound, briefly turning it up then turning it back down. This example shows how to create a trapezoidal window on a sound file, which will quickly fade the file in and out for a specified duration, repeatedly at some specified triggering interval. The metro triggers a message to the line~ object.

Click resulting from amplitude change

The amplitude of a sound is controlled by multiplying the sound wave by a certain factor. A multiplier of 1 represents "unity gain", meaning no change. Multiplying by a factor between 0 and 1 reduces the amplitude of the sound. However, if the multiplier is changed very suddenly and significantly, it may create a sudden discontinuity in the waveform which will be heard as a high-frequency click.