Joysticks!
It’s not the most attractive piece of gear on my desk, but in terms of cost, size, and getting a bunch of gestural control into Max, it’s hard to beat the humble game controller. It’s my go-to response when new users ask what their first gear purchase should be, despite a constant stream of new MIDI hardware with glowing buttons and glossy knobs. They are affordable, easy to toss into a bag, super easy to work with in Max, and provide 4 axes of gestural data at the tips of your thumbs.
When I started using Max in 2003, there wasn’t a big variety of readily available and user-friendly microcontroller boards like Arduino to get your hands on, but it was easy to find second-hand PC joysticks in the Thrift Town electronics section. Once I discovered how to modify the circuitry inside, and how to connect it to Max through the Max hi object, I was set for a few years of interactive media projects. For a guide on how to get started with that, check out my “Making Connections” tutorial.
While hacking an off-the-shelf controller has a certain romantic charm to it, you might want to build your own device from scratch. For this task, the Teensy series of microcontroller boards from PJRC (available from Adafruit) ship with a demo firmware that implements a basic joystick controller without much work. Just add your own components and connect 'em up to your Max patch using the hi object.
Once you’ve got a joystick connected to Max, there are a few tricks you’ll want to know about working with that data coming out of the hi object. You’ll want to use the the route object to parse out individual axes and buttons to different outlets. The buttons will give you a simple 0/1 output, and can be used anywhere a toggle might go in your patch. The analog sticks will give you 2-axes each of integer values within some range, depending on the bit resolution of your controller. The most obvious way to use the analog values will be to scale and map them directly to parameters using the scale, zmap, function, and table objects commonly employed for this purpose.
Another way to look at that analog data is to think of it as coordinates in a 2D space. This was the inspiration for the nodes object, which takes a pair of coordinates in the range of 0. - 1.0 and spits out weighted values based on proximity to each node. These weights can be used to set up spatial regions for sample triggering, mapped directly to parameters in your patch, or used to drive the interpolation of a pattrstorage object for parametric morphing. Check the nodes help patch for more ideas of how to use the object.
The best part of using a game controller with your Max patch is that it encourages you to have fun, play with your sounds, and experiment in ways that a ready-for-music controller might discourage. Have your own game controller patches to share? Let’s see them in the comments.
by Andrew Benson on June 22, 2016