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.

Amplitude envelope with the function object

Each MSP object (each object that has signal input and/or output) is always producing signal as long as audio is turned on. For example, signal generators like cycle~ (sinusoidal wave generator) and saw~ (band-limited sawtooth wave generator) are always producing a full-amplitude wave. You control the amplitude of that wave with multiplication, using *~ or some other object that performs a multiplication internally (such as gain~).