MSP

Determine the length of a buffer~

This example shows how to retrieve the total duration in ms of a loaded file in a buffer~, using the info~ object. In fact, because the buffer~ object sends a bang out its right outlet whenever it loads in a sound file, you could use that bang to trigger info~, thus automatically obtaining the duration of any sound file you import.

Sine Wave into Buffer~

The cycle~ object allows you to read from a stored cosine function (use a phase offset of 0.75 to get a sine phase), and does high-quality interpolation to give you excellent resolution even though it only uses a 512-sample table. (See MSP Tutorial chapters 1-3).

But if you want to put a sine wave into a buffer~, here’s a way:

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.

MIDI stream to exponential curve

In this patch the zmap object changes the scale of the incoming number stream from the ctlin object from the standard range of MIDI (0-127) – the 0 is bypassed so that it is translated properly once the range is mapped back to linear amplitude – to a specified range in decibels – in the case of the example from -63 to 0 dB.

Delay effect with feedback

Some interesting effects can be obtained by feeding the output of a delay line back into itself and adding that to whatever new sound is coming in. The result is delays of delays, echoes of echoes, etc. As was shown in the discussion of Comb filtering, short delays fed back at a specific rate will have a strong resonance effect on the timbre of a sound.