MSP

Generating a simple 2-operator FM tone

In order to enable and disable portions of an audio program easily, and to be able to reuse them multiple times, you will probably want to encapsulate an entire audio-generating or audio-processing procedure inside a single patch with inlets and outlets so that it can be used as a subpatch object in some other patch. This patch shows an example of a simple 2-oscillator frequency modulation tone generator that could easily be used as a subpatch in some other patch.

Polyphony requires multiple objects

Any given MSP patch cord represents a single channel of audio. If you want to generate or process multiple sounds or channels, you need to treat each sound or channel separately. For example, each sfplay~ object can have multiple loaded sound cues so that it's ready to play any one of several files, but it can only play one sound file at any given instant. And if it's a stereo file you need to treat each channel separately for mixing, processing, etc. This patch demonstrates that.

Linear interpolation to a new value

The rampsmooth~ object is useful for smoothing MSP signals, a sort of lowpass filter, especially appropriate for smoothing out overly sudden changes in control signals. The left part of this patch demonstrates the fact that internally rampsmooth~ is just doing linear interpolation. Whenever the input signal changes, rampsmooth~ heads toward that value from wherever it currently is, using the specified number of samples (depending on whether it has to increase or decrease) to get there.

Non-UI version of live.gain~

The live,gain~ object is terrific for volume control of audio signals. It allows you to attenuate the volume down to -70 dB (by default), at which point it turns the volume completely to 0. In addition to the user-interface fader that live,gain~ provides, you can set the volume with a float message, in decibels, and it will quickly interpolate (in 10 ms by default) to the new volume to avoid clicks due to sudden changes.

Indexing and accessing the bins of an FFT

The Fast Fourier Transform (FFT) is a mathematical procedure for converting a time-domain signal (such as a sound wave) into an equivalent frequency-domain representation (the sound’s spectrum). The inverse transform (IFFT) reverses that process. The Max object pfft~ allows you to encapsulate an FFT and IFFT (with the objects fftin~ and fftout~ respectively) and program some sort of frequency-domain processing (alteration of the spectrum) between the two.

Panning between four front speakers

This patch is an abstraction for panning a sound source among four speakers arranged in a row—or more precisely, in an equidistant arc—in front of the listener. The sound’s virtual location in the stereo field, from extreme left to extreme right, is specified as a control signal value from 0 to 1. The four speakers define the boundaries of the three regions between them, each of which constitutes one third of the total stereo field.