MaxMSP needn't be as scary as you might think, as we demonstrate with some basic Max For Live programming.
Last month, we presented a 'state of the nation' overview of Max For Live, to give an indication of the weird and wonderful things that are being done with it. On the assumption that this has made you sufficiently curious to try out Max For Live yourself, in this column we're going to walk through some very simple examples to show how it works and how you might think of using it to start creating your own effects.
In a very broad sense, MaxMSP can be regarded as a kind of gigantic modular synthesizer that can never run out of modules. It knows how to process audio and MIDI, and can do quite a few things that are easy in software but would be somewhat challenging for a real modular synth, such as scrubbing from audio files or sampling.
One thing that MaxMSP and modular synthesizers have in common is that they are, in a very real sense, musical instruments, and require a degree of training or, at the very least, some commitment to study to be truly productive with them. The purpose of this article then, is not to try and convince you that MaxMSP via Max For Live is easy to use — that would be no more true of MaxMSP than it is of a modular, or of a violin — but to demystify MaxMSP, show how it works, and prove that there's no reason to be scared of it. The rest — becoming productive, and eventually fluent — is up to you, but it's possible to take small steps and do useful (and fun) things incrementally.
Time to get our hands dirty. In the Live Device Browser, select the Max Audio Effect and drag it into an audio track. You should see the Max For Live splash screen for a few seconds as Live loads up its Max component, and then you'll have a basic Audio Effect sitting in the Track View, as shown in the screen below. This is about the simplest possible effect, taking a stereo input and passing it unchanged to the output: it's basically a pair of virtual jack cables, one for the left channel and one for the right. The 'plugin~' box is the audio feed coming into MFL from Live itself, while 'plugout~' routes audio from MFL back into Live. If you drop an audio file into a Session Clip in the track and play it, you should hear your original audio, and also see identical signal levels in the small VU meters on the input and output sides of the effect, proving that it's simply operating as an audio 'through'.
Now for a bit of editing action. If you look at the Device's title bar, you'll see the Edit button, just to the left of the hot‑swap and preset-saving buttons. Click this and a full version of MaxMSP will be launched to do the actual editing, showing the Effect in its own window.
The copy of the Device in the Live window is now greyed out, to indicate that it is inactive; the copy that's open in Max is the one that is running, as audio is now being routed from Live into Max and back out again. If you close the Max window, the copy of the Device inside Live will become active again and you'll be back where you started.
Open the Device for editing again and click to select one of the audio patch cords (the vertical striped lines): it should highlight with diamond icons at its ends (green at the top, red at the bottom), which you can think of as the virtual jacks on the virtual patch cords. Try dragging each red diamond across to the opposite input (MaxMSP calls them 'inlets') on plugout~, and you should end up with a crossover network, as in the screen to the right. If your audio Clip is playing while you do this, you'll hear one or both channels cut out — just like with real patch cords — and you should end up with an effect that is swapping the left and right channels of your original stereo input.
(If you don't see any diamonds, don't panic: it probably means you have a Max version earlier than 5.1.4. Try deleting the patch cords completely using the DEL key and dragging new ones from plugin~ to plugout~ instead.)
Congratulations: you're now a Max programmer! Save and close the Device in Max (the location of the file on disk isn't important for the purposes of this article) and your altered Device will appear back inside Live.
Editing Devices in Max is intended to feel very much like altering your studio's MIDI and audio hardware while you're using it to record and play music but, unlike real hardware, there's no messing around with soldering irons, and it's very hard to break anything: Max has an indefinite‑level Undo command, and you can always close a Device without saving it if you make too much of a mess.
At this stage I'm going to have to pull a trick a bit like Blue Peter with their 'and here's one I made earlier' ploy, which invariably transforms a couple of old toilet rolls into an uncannily accurate model of Tracy Island. There's no room in this article to cover all of the essentials of Max programming, but MaxMSP does come with an excellent on-line help system and a varied set of tutorials. Under the Help menu, select 'Max Help' and you'll find yourself presented with a selection of incremental guides to using Max. I'm going to jump ahead a little, and rely on Max's Help to fill in the gaps.
Now for some MIDI. We'll tackle the most obvious MIDI 'effect' in the book: note transposition. MIDI is a bit more complicated than audio, since it involves messing around with numbers and messages. To begin, drag the Max MIDI Effect from the Device Browser into a MIDI Track in Live and you'll have a simple MIDI processor that passes all MIDI from its input to its output, as you can see in the screen below. You may also want to drag an instrument into the Track View to the right of the MIDI Effect, and route a MIDI keyboard into the track, in order to hear what you're actually doing.
Again, open the Device for editing in MaxMSP. You'll notice that it is routing information from 'midiin' to 'midiout'. Instead of audio, this is the raw numerical data representing MIDI messages.
Click the 'midiin' box and replace the text with 'notein'; similarly, replace the word 'midiout' with 'noteout'. You now have a couple of slightly smarter Max boxes that deal with MIDI notes' pitch, velocity and MIDI channel. This is why 'notein' has three outlets and 'noteout' has three inlets. Drag a patch connection from each outlet to the corresponding inlet and you have a MIDI effect that behaves just as before, echoing MIDI notes. (Actually, it differs from the 'midiin'/'midiout' version in a rather important respect, which I leave as an exercise to the reader! Feel free to create a second MIDI track, copy the default Max MIDI Device into it from the Browser, and see how the two compare.)
Now for the actual transposition part. Since MIDI represents the pitch of a note as a number (where Middle C is 60), we can implement a simple octave transposition by adding 12 to the pitch component of any notes we play. In the MaxMSP window, type 'N' (to create a new Max object) and then type '+ 12'. You now have an object that adds 12 to things. Remembering what we did with audio patch cords earlier, you should be able to wire this '+ 12' object into the MIDI Effect so that it affects the pitch values coming from the 'notein' — while letting the velocity and channel values go unaffected. The results should resemble the screen below. OK, so it's not the world's most sophisticated transposer (for a start, it could do with a 'transpose amount' knob, like Live's own Pitch MIDI Effect), but it serves to illustrate what MIDI looks like in the Max For Live world.
We'll close with a brief and tantalising look at how deeply a Max Device integrates within Live itself. Go back to a new Max Audio Device, open it in Max, and create a new object by typing 'N' and then the name 'live.gain~' (that's 'live‑dot‑gain‑twiddle', but Max should auto‑complete the name as you type). You'll end up with a Live‑style fader that has VU meters you can wire up to make a volume control device, as shown at the top of the opposite page. Close the Max window and switch to Live's Arrangement View: you'll notice that 'live.gain~' is available for automation. All of Live's automation, MIDI controller mapping and preset management machinery comes for free in Max Devices, making them a powerful part of Live's tool set.
Hopefully, this article has served to show what Max For Live is and how it works, and persuaded you that it may be worth taking a few steps into the unknown.