MSP

Envelope function without a fixed starting point

The function object permits you to design a shape made up of line segments, and then you can send that information (out the second outlet) to a line~ object to cause a changing signal with that shape over a specified amount of time. When the function object receives a bang, first it sends out its initial value as a float (0. in this case), then it sends out a list of subsequent values and destination times.

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.

Random pitch variation of an oscillator

If you want to make an oscillator with unstable pitch, you can modulate the pitch of the oscillator using a noise signal as an exponent with a base of 2, and applying that as a multiplier to vary the fundamental frequency. In that way, when the noise ranges from -1 to +1, it will cause a pitch variation of ±1 octave, whatever the fundamental frequency of the oscillator. Divide the amplitude of the noise by 1200 if you want to be able to represent pitch variation in cents.

Open a sound file and play it

This shows an extremely bare-bones program for audio file playback.

1. Click on the speaker button (ezdac~ object) to turn audio on.

2. Click on the word open (message object) to open a dialog box that allows you to select a sound file. (In the dialog, select a WAVE or AIFF file and click Open).