MSP Polyphony Tutorial 4: Audio-Rate Control Data
Click here to open the tutorial patch: 04hAudioRateControl.maxpat
This tutorial looks at using the poly~ object to generate low-frequency oscillators (LFOs) to generate control-rate data for Max objects. There are many tasks in Max (such as graphics) that don't require control updates at audio rate (44,100 per second, or higher), and simply need to receive new values regularly at a lower speed. For example, a video processing patcher running at 30 frames per second would only need new information for all of its parameters every 33 milliseconds. At the same time, MSP signal generators make excellent choices for designing periodic sources of control information. The poly~ object has a simple way to downsample the audio processing in an abstraction, so that it can be used to create control-rate data in Max without the CPU overhead of working at audio rate.
- Take a look at the tutorial patcher. Turn on the dac~ (on the right) and the metro (on the left) using the toggle objects. You should see a line being drawn in the lcd object on the right of the patcher. At any point, you can hit the space bar to
clearthe drawing. * In the number boxes labeled
1.3, respectively. Look at the curve drawn in the lcd. Clear the lcd with the space bar and change the values to
4.. Notice that when the values are in an integer ratio the pattern begins redrawing itself after a while. Try your own numbers, or changing them as they go. Using cosine waves of different frequencies as the X and Y inputs of a drawing surface (such as an oscilloscope) creates something called lissajous curves. These patterns visually describe complex harmonic motion, so that X and Y patterns in simple ratios will create pre-determined repeating shapes.
- Double-click one of the poly~ objects to see inside the
polylfo1~abstraction. Notice how simple our abstraction seems, with an in object allowing use to set the frequency of a cycle~ object. A second in object provides
bangmessages to a snapshot~. The snapshot~ object allows us to capture single values of MSP signals as floating-point numbers generated as Max events. Whenever a snapshot~ receives a
bang, it samples the current MSP signal at its inlet and outputs that one sample as a floating-point value. In our tutorial, this value then goes to an out object, and back into our main patcher.
- Close the abstraction
polylfo1~and return to the main tutorial patcher. Click on the message boxes in the middle that begin with the message
patchernamemessage reloads a poly~ object with a new abstraction. Notice the effect on the drawing, depending on which you select and whether it applies to the X or Y poly~ object. Select
polylfo2~and double-click the poly~ object to see it. The
polylfo2~abstraction does the same as
polylfo1~, but generates its output as a sawtooth wave rather than a cosine wave. The phasor~ object generates ramps from
1, so we scale the output to go between
1with the *~ and -~ objects before we sample it with the snapshot~
- Switch one of the poly~ objects to
polylfo3~and look inside. The
polylfo3~object generats a triangular output by using a triangle~ object. The triangle~ object wraps a phasor~ around a midpoint, essentially translating it into a triangular waveform. This object outputs values between
1, so it doesn't require any scaling.
- Close any open abstractions and return to the main patcher. Look at the arguments to the poly~ objects. When working with an abstraction inside of a poly~ object, you can decide to work at a lower or higher sampling rate than your main MSP patcher. This rate is not specified directly, but as a divisor or multiplier of the main rate. The arguments
up 2will make the poly~ run at twice the sampling rate of the main patcher. The arguments
down 8, as shown here, run the audio within the poly~ objects at one eighth the normal speed (i.e. 5.5125kHz if the main patcher runs at 44.1kHz). Since we're only sampling our oscillator values once every frame of the drawing (set by the metro speed at 50Hz or every 20ms), this is more than enough resolution for our control data.
- Mix and match different LFO curves by choosing different poly~ abstractions run at different frequencies. Notice how the Lissajous curves behave with the different waveforms.
The poly~ object can work at a different sampling rate than its host MSP patcher. The
down arguments allow you to specify a multiplier or divisor for the main sampling rate. When designing LFOs (low frequency oscillators), it's often useful to use massively downsampled MSP patchers inside of poly~ objects to generate the curves efficiently. the snapshot~ object allows you to sample a single value from an MSP signal in response to a
snapshot~ - Convert signal values to numbers