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. 8: This figure shows the audio delay line function encapsulated in a Max Patcher Object. Double clicking on the Object labeled “patcher delayline” will open the second window, revealing the contents of that Patcher Object. Inlet and outlet Objects are used to designate inputs and outputs to appear on the completed Patcher Object.
KEEP IT CLEAN
I will now reveal to you the secret of making useful programs with Max/MSP: make sure you keep your Patchers neat. That's the difference between a hacked-up Patcher that falls apart and a complete, usable, and maintainable program. Keep your Patchers organized, and you can do anything you want.
Max provides excellent facilities to build complex functions with good organization, visual sense, and flexible design of the user interface. To start with, you can encapsulate an entire Patcher in a single Object. When you make a new Patcher Object, a subwindow automatically opens where you can construct an entire function and link it into a larger Patcher.
Fig. 8 shows our delay module with the core delay function incorporated into such a subpatch. Inputs and outputs are defined in the subpatch by using “inlet” and “outlet” Objects, which appear like the inputs and outputs of a native Max Object. When configuring a subpatch in this way, it's a very good idea to add labels for the inlets and outlets. Number boxes inside the Subpatcher are handy for debugging, as well.
I also cleaned up our patches by using right-angle lines for patch cords instead of diagonals. To do that, select the item Segmented Patch Cords in the Options menu. When connecting Objects, you can create breaks by clicking on the cords with the mouse. I use segmented patch cords in all of my work with Max, restricting use of diagonal cords to short runs where segmented cords would be awkward.
It also helps to organize Objects that connect to each other into vertical columns or horizontal rows using the Align Objects command. Simply select all of the Objects to be aligned and use the keyboard shortcut (Command + Y) to snap the selected Objects into line.
FIG. 9: The knob Object can be used to set gains instead of number boxes. Knob Objects in Max output numbers ranging from 0 to 127. To use these to set gain at a maximum value of unity, it is necessary to divide the raw output by 127, using a floating point divide, as indicated by the decimal point in each divide Object.
Number boxes are also not the ideal way to control audio gain. Max provides slider and knob Objects for more conventional audio control. Fig. 9 shows our patch with knobs instead of number boxes for the gain parameters. The knob Object outputs numbers from 0 to 127, but the gain-control multiplier needs to see a range of 0 to 1.0. To convert, divide the knob output by a fixed value of 127 using a floating-point divide so decimal values between 0 and 1.0 will be output.
FIG. 10: The Hide on Lock command in the Object menu is a powerful means of maintaining Patchers so that they look clean and neat to the end user, with wiring and Objects that the user doesn’t need to see hidden from view.
Another way to help maintain visual organization is to hide connections and Objects that the end user doesn't need to see. To do that in Max, unlock the Patcher, select the item or items you wish to conceal, and then select the command Hide on Lock from the Object menu. When you relock the Patcher, all of the Objects that were selected will be concealed, as shown on the right of Fig. 10. All patch cords and Objects that the user doesn't need to see are now hidden from view.
I elected to leave the delayline Patcher Object visible for two reasons. The first is that in order to edit a Patcher Object, you have to double-click on it while the main Patcher is locked. If the Patcher Object is hidden, you can't do that. Second, it is also helpful to embed the main function of a Patcher in a single Patcher Object and then keep that Object visible. For one thing, it helps to remind me of what that particular Patcher does for a living.
Making your Patchers orderly is an art, and you should adopt the practice from the start of your work with Max. Spaghetti Patchers get out of hand very quickly.
FIG. 11: The loadbang Object triggers specific actions when the Patcher is opened, ensuring that the Patcher always comes up in a known, useful state.
MAKE IT NICE
It's a good idea for you to include some initialization so that your Patchers come up running in a known state. An Object called “loadbang” can help make your Patchers initialize properly. Fig. 11 shows the previous version of the delayline Patcher with initialization added to load a known set of values and to start audio processing automatically.
In the Patcher shown in Fig. 11, I've unhidden some of the Objects and cords and added notes to make clear what's happening there. Whenever the Patcher is opened, loadbang sends out a trigger pulse called a bang. In this case, the bang goes to two separate places.
The first is to a Max preset Object. This is one of Max's magic functions, storing a preset for an entire Patcher window. In this illustration, a preset has been loaded into “memory 1.” Loadbang triggers the message box, sending the number “1” and loading that setup.
At the same time, loadbang triggers the “delay 500” Object. After a half second, this Object sends the start message to begin audio processing. That ensures that the whole Patcher is up and running before processing begins.
Acceptable Use Policy blog comments powered by Disqus
Want to use this article? Click here for options!
© 2009 Penton Media, Inc.












