Simple audio mixing with matrix~
This examples shows a way to choose automatically from a list of preestablished sound cues, with a crossfade between cues rather than a sudden switch.
To do this we have two stereo sfplay~ objects, both of which refer to the same list of sound cues in an sflist~ object, named "cuelist". Instead of sending open and preload messages to each sfplay~ object, you can send those same messages to a single sflist~, and then the sfplay~ objects refer to that object by its name.
This example shows how to use the matrix~ object to route an audio source—in this case the adc~—to different effect patches represented by the patcher objects.
This patch allows you to see and hear the sum of up to 16 harmonically-related sinusoidal tones, mixed with equal amplitudes. The sinusoids are all in cosine phase. (If the phases were different, the sum would look different, but it would sound pretty much the same.) As you add a number of tones together, you'll need to adjust the volume to avoid clipping.
The most direct and usually the best way to "turn off" a signal in MSP is to multiply it by 0. However, even if a signal is multiplied by 0, MSP still works to compute that signal. So, if you need to conserve CPU usage, it's best to disable the computation of that signal once it has been silenced, then re-enable it when you want to turn it up again.
The matrix~ object is a multichannel audio mixer. It’s useful as a mixer of sounds, and also as an audio switcher/router, because you can route any input to any output, with built-in interpolation for smooth, click-free amplitude changes.
This example shows how to control the amplitude of multiple signals with the matrix~ object, instead of with line~ and *~ objects. In effect, matrix~ has the linear interpolation and multiplication capabilities of those objects embedded within it.
An exponential amplitude fade is usually more subjectively natural-sounding than a linear amplitude fade. This patch allows you to compare the two.
The matrix~ object is an audio mixer/router that can be configured with any number of inlets and outlets. The arguments specify the number of audio inlets, the number of audio outlets (there's always one additional outlet on the right), and the initial gain for the connections of inlets to outlets. Each inlet is potentially connectable to each outlet with a unique gain setting. The gain of the connections is changed by sending messages in the left inlet.