Mapping one range of values to another needed range of values is a crucial technique in computer music. In this example, we want to map MIDI data values that range from 0 to 127 into a useful range for controlling the amplitude—and thus the loudness—of a sound in MSP.
The phasor~ object produces a linear control signal that goes repeatedly from 0 to 1. That's demonstrated in the upper left part of this patch. In general, a control signal that goes gradually in a straight line from one value to another is quite useful, but you don't always want it to repeat over and over the way that phasor~ does.
For speakers that are configured in a circle or in the vertices of a regular polygon, you can give a sense of localization of a sound by calculating the radial angle of the sound's desired virtual location relative to the center of the listening space, and then panning the sound between the speakers that are closest to that virtual location. In other words, for any virtual location that you want to imply, you need to calculate which speakers are closest to that location, and then pan the sound between those speakers.
This patch shows the lookup tables (a.k.a. transfer functions) being used on three formal levels: 1) the microscopic level, to determine the timbre of the waveform, 2) the note level, to determine the amplitude (and timbre) envelope, and 3) at the phrase level, to control the amplitude over a 15-second time span.
First, turn on audio (below), then start the tempo object.
This patch demonstrates the use of the cycle~ object to control quadraphonic panning in such a way as to simulate circular movement of a sound. It's an abstraction that can be used inside another patch to provide 4-channel distribution of a sound source. This abstraction uses another abstraction, which in turn uses another abstraction.
In Max, the message bang is used as an all-purpose triggering message, to cause some event to happen. Most Max objects understand the message bang to mean "do whatever you do". In other words, the message bang is used to cause some event (such as playback of a sound file) to occur.
Two low-frequency phasor~ objects with slightly different frequencies can create a rhythmic pattern determined by the ratio of the periodicities of the two LFOs. As an example, this patch uses two phasor~ objects with a frequency ratio of 4.5:4, which, when added together, create a 9:8 rhythmic ratio that repeats every two seconds. That pattern is scaled and offset and used to provide frequency information to a cycle~ object, which is being used as the carrier oscillator.
This simple program allows you to listen to a sinusoidal tone with any desired frequency and amplitude. Initially both frequency and amplitude are set to 0, so you'll need to set the frequency to some number in the audible range, and you'll need to increase the amplitude to some value greater than 0 but not greater than 1. The speaker icon (ezdac~ object) is an on/off button for audio, and sends the output signal to the DAC.