advertisement
|
CURRENT NEWSSTAND ISSUERead the full Table of Contents for the issue on sale now! Click here Subscribe for only $1.84 an issue! Please tell us about yourself so we can better serve you. Click here to take our user survey. |
| |
![]() |
Life in the Fast Lane This collection of St.CroixÕs columns was assembled during the two years following his death of cancer in May 2006. Included are many of his most-read columns, as well as personal notes, drawings and photographs. Click for more books |
![]() Listen to these latest podcasts and more: |
|
eDeals Newsletter for Discounts on GearGet First Dibs on Hot Gear Discounts, Manufacturer Close-Outs and Job Opportunities when you sign up to receive eDeals E-newsletter, sent twice a month. Check out an issue get advertising info or subscribe |
|
FIG. 1: Max/MSP’s Audio Through Patcher accepts a stereo signal from the audio interface and passes it directly to the audio output. To understand Max and the operation of these example Patchers, pay special attention to the comments.
MAX/MSP AUDIO PROGRAMMING
In an article such as this, there's no way to describe the complete ins and outs of programming with Max and MSP. For that, the best source is the excellent documentation, tutorials, and Help system that come with the package (also see the review of Max 4.0/MSP 2.0 in the April 2002 issue). But let's take a look at the basic principles of operation.
In Max, low-level functional blocks, which are called Objects, are connected together in Patchers. Fig. 1 shows a simple Patcher that passes stereo audio from input to output. Notice the descriptive text that appears alongside the Patcher itself. Comments such as those can be instructive to someone attempting to use your Patchers or to you to remind you how a Patcher works. You can download and run this Patcher, but the best way to learn is to build it from scratch in Max/MSP.
There are three kinds of Objects used here. The “adc~” Object gets input from the audio interface, “stereo by default.” Audio data is transferred from the outputs of adc~ to the inputs of the “dac~” Object by virtual patch cords. The dac~ Object outputs stereo audio to the audio interface.
The remaining Object in this Patcher is a message box that contains the word start. A start message is required to initiate processing of audio. To make the Patcher operate, click on the start message. A separate stop message can be used to halt processing.
There's an important distinction in Max/MSP between Objects that handle audio data and those that deal with control and MIDI information. Max Objects for control and MIDI process data only when stimulated by the user interface or incoming messages. MSP audio Objects, on the other hand, process audio data continuously.
FIG. 2: The Through with Gain Control Patcher adds stereo gain control to the simple Audio Through. The initial gain is 0.5, but the gain can be controlled by click dragging on the number box.
MSP audio-processing Objects are distinguished by a tilde (“~”) sign after their names. In many cases, Objects of the same name are available in control and audio form. For example, the Object “*” will multiply two numbers, whereas the Object “*~” multiplies numbers in a continuous stream of audio data for gain control and modulation, as shown in Fig. 2.
Note that Max supports the Apple Sound Manager and ASIO drivers. To use your ASIO interface, put the driver into the ASIO Drivers folder in the Max application folder. Then, open the DSP Status window by double-clicking on an adc~ or dac~ Object in any Patcher (or by selecting DSP Status in the Options menu) and make the appropriate selections for your interface.
FIG. 3: When a Max/MSP Patcher is unlocked, the Object toolbar appears at the top of the window. Although there are a large number of different Max/MSP Objects available, the seven leftmost items in the toolbar are the ones that are essential to nearly any project.
To build and modify Patchers in Max, you unlock the Patcher window by clicking on the lock icon next to the Close box. If you're running the Patchers with the free Max run-time application, that icon doesn't appear. Try creating a new, empty Patcher. With the Patcher window unlocked, you will find that it is easy to get started by dragging Objects from the upper toolbar and then connecting their outlets (which are found along the bottom of each Object) to the inlets of other Objects. When you drag from the Object tool, which is leftmost in the toolbar, into the main Patcher window, a handy index of the available Objects pops up, and it is sorted into functional groups (see Fig. 3).
FIG. 4: The Help window for any Max or MSP Object is a completely commentated working Patcher that illustrates the full function and options for that Object.
Max/MSP uses a Help system that I really like. When a Patcher window is unlocked, you can pick any Object and then go to the Help menu and get a Help screen specific to that Object. The Object Help window is itself an active Max Patcher that illustrates the full function and options for that Object, complete with comments. You can run the Help Patcher Object as is, or you can unlock it and modify it to see how the Object behaves. Fig. 4 shows the Max Help window for the adc~ Object.
BASIC AUDIO DELAY
Now we can have some fun. In Max/MSP an audio delay line requires two separate Objects, which are “tapin~” and “tapout~.” Tapin~ creates the delay unit and uses a numeric argument that defines the maximum delay in milliseconds. You then connect the output of the tapin~ to tapout~'s input. Tapout~ has a numeric argument that defines the actual audio delay; that can be changed by sending a number to the Object's input.
FIG. 5: This Patcher is a simple audio delay line with variable delay time. Left and right audio inputs are mixed together, delayed, and then distributed to both audio outputs.
In the Patcher shown in Fig. 5, the left and right audio inputs are connected to the input of tapin~. In Max/MSP, audio sources connected to the same input are summed together at unity gain, which makes audio mixing easy.
FIG. 6: This version of the delay line adds controls for feedback gain as well as level controls for direct and delayed audio. The decimal points in the arguments for the audio multiply (*~) Objects and in the number boxes that set the gains are necessary to make those Objects work in fractional values, in this case zero to unity gain.
If you run the Basic Audio Delay Patcher, you'll find that it does in fact delay audio. However, audio delay is not much fun unless you have a way to mix it with the direct signal and to feed the delayed signal back to the input with some attenuation. Fig. 6 shows an audio delay that provides those functions.
At this point, a couple of notes about numbers in Max/MSP are in order. There are two kinds of numbers available: integer numbers (0, 1, 2, and so on) and floating-point numbers (floats) that can have noninteger values (0.5, for example). By default, Max uses integers. Audio gains, though, are usually fractional (in a range of 0 to 1.0, typically), so it's important to use Object types that are compatible.
Arithmetic Objects such as the *~ Object are made compatible with floating-point numbers by entering an initial argument with a decimal point. Similarly, number boxes such as those we're using to vary the gain values come in two types. These are represented separately in Max's toolbar and are denoted by a decimal point in the floating-point number box.
FIG. 7: The Number Inspector (select the number box and hit Command + I on keyboard) defines important properties of the integer or floating point number box, including the number range. Defining the range of each box appropriately will help to make your audio patches behave as you intended.
It's also important to limit audio gains to appropriate values, usually unity. To limit the range of values in a number box, unlock the Patcher, select the number box in question, and hit Command + I on the Mac keyboard. This opens a dialog that controls the numeric range, as well as other properties of the number box (see Fig. 7).
By the way, if your audio interface provides a direct-monitoring path, you can delete the portion of the Patcher that feeds the direct signal to the output. That is a better way to monitor the direct sound, because routing audio through the computer always entails at least a few milliseconds of latency.
Acceptable Use Policy blog comments powered by Disqus
Want to use this article? Click here for options!
© 2009 Penton Media, Inc.












