amplitude

Amplitude is inversely proportional to distance

Our tympanic membrane (a.k.a. our eardrum) and a microphone are both devices that measure sound intensity. When a sound arrives at our eardrum or at the diaphragm of a microphone, either of which has a certain surface area, the power in that area (i.e. the intensity) is detected. However, the intensity of a sound, as measured by an eardrum or a microphone, will differ depending on the distance from the sound's source, because the sound is being emitted from the source in all directions.

Amplitude and decibels

A linear fade-in or fade-out of audio is okay for quick changes that take place in a fraction of a second, but for slower fades one should generally take into account that our subjective sense of loudness more closely conforms to an exponential change in amplitude. This patch allows you to use the slider (or the mod wheel from a MIDI controller) to control the amplitude of white noise in one of three different ways: with straight linear mapping, exponentially (with an exponent of 4), or using a range of 60 decibels.

Smooth Output of Peakamp~

The peakamp~ object can be used to take the amplitude of one signal and have it control the amplitude of another. Peakamp~ takes a low-frequency sample of the peak amplitude of the signal, which is then smoothed by the line~ object. This gives an intuitively much more accurate representation of the audio signal one is envelope-following than does smoothing the audio signal itself, which tends to smooth out — and thus lose — all the more interesting characteristics of the signal. Here’s an example that lets you compare.

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~).

Audio amplitude control

As explained in MSP Tutorial 2, in order to avoid creating clicks in audio when you change the amplitude, you need to interpolate smoothly from one gain value to another. Example A in this patch shows how to use the line~ object to do that. The gain value from the number box is combined with a transition time in the pack object (10 ms in this case) and the two numbers are sent as a list to line~.

Control the balance between two channels of audio

This abstraction allows you to adjust the balance between two channels of audio. The audio channels come in the first two inlets, and a control signal comes in the right inlet. When the control signal is 0, the two channels pass through unchanged. As the control signal approaches -1, the amplitude of the right channel is reduced (till completely silent at -1) while the left channel remains unchanged; as the control signal approaches 1, the amplitude of the left channel is reduced (till completely silent at 1) while the right channel remains unchanged.

Stop a modulating oscillator

When you want to turn off an oscillator in MSP, you don’t literally stop it or turn it off, you just turn its amplitude to 0; you multiply it by a constant value of 0 so that the resulting signal is 0. Setting an oscillator’s frequency to 0 does not turn the oscillator off, it just stops it dead in its tracks. (It is completing exactly 0 cycles per second, meaning it’s going nowhere.) It will continue to output whatever value it was at when its frequency was turned to 0, which in all likelihood will not be exactly at the value 0.