Thursday, May 20, 2010

how i use my iphone as a wireless MIDI controller: step-by-step

so..... you're on the road, mobile studio in tow. but, you left your nanoKey at home and, well, you want to have keys there for sound design, tapping out melodies... whatever!!! well, if you have an iphone, ipod touch or iPad in tow, you're in luck.

first, the following describes the setup on a PC. it's much easier on a mac, from what i gather, but this is a PC only guide.

second, what do you need before getting started?

1. TouchOSC (or mrmr, or something similar, but this write-up assumes TouchOSC) installed on your iphone.

TouchOSC is the iPhone application which hosts the User Interface that will be your MIDI controller, and also that which transmits OSC messages. what is OSC? it stands for Open Sound Control, and basically gives you the ability to transmit data across a network to a compatible host allowing for the control of software synths, controllers, etc. the possibilities really are endless. read more here: Introduction to OSC

(NOTE: TouchOSC requires iPhone OS 3.1.3. many of you may have no updated your OS to 3.1.3, due to it's lack of significant features. i also heard that some people "jailbreak" their phones... but, from what i gather, all is good even after a 3.1.3 update if you use rock restore)

2. Pure Data extended (you can get that here: Pure Data Extended Download):

Pure Data is just one of many ways to receive OSC messages. it is most flexible in that it allows you to build UI objects that match your controller UIs in TouchOSC, thereby giving you not only a graphical representation of your UI from which to code your OSC controls, but also a visual response to ensure your OSC setup is working correct.

Pure Data may look familiar to those of you who have spend any time using Max.

after installing Pure Data, download a simple midi controller template from here.

when you have Pure Data installed, double click the midi controller template you just downloaded. you should see a screen that looks like this:

some things we should note here:

- reference the top right. you'll see an object called dumpOSC. the number follow, 8001 in this case, is the local server port where OSC messages will be processed.
- reference the connections, like virtual wires. each page is linked to a specific OSCRoute object instantiation.
- the UI!! not super pretty, but don't worry, you'll be happy. what you can see represents a standard set of keys, green for the white ones and purple for the black ones.

i'm not going to get super in-depth about the back end of this, but if you really want to know, it's very easy to decipher. one easy change that i've made in this particular template is to change the server port from 8000 to 8001, as there was a conflict on my local network with port 8000. to do this, you simply open the edit menu and select "Edit Mode". then, double click the dumpOsc object and edit it as plain text. don't forget to leave edit mode, save and re-start the template.

3. TouchOSC Editor:

this is a client version of the TouchOSC interface, allowing you to build templates on your local machine and sync them with TouchOSC. you can download it here.

one thing to note is that the TouchOSC Editor requires the java 1.5 jre to be installed on your machine. i tried using 1.6 and didn't have much luck, but all works well with 1.5.

i'm not going to cover this one, because it's very simple to use... and also because the layout i am referencing in this post (Keys) is already installed by default in TouchOSC.

(optional) 4. Bomes Midi Translator

i list this as optional because you can also use MIDI-Yoke, which is free ( essentially, what we need to do is use a virtual MIDI port to receive and route MIDI messages to the appropriate places.

Bomes Midi Translator is an extremely functional product that allows you to do the above, but also to translate Midi messages into just about anything you can imagine. for example, we can create arbitrary key strokes in a controller, receive those messages and translate them into things like pressing play, toggling views/tracks, triggering record, opening files, etc... like i said, it's quite endless and i can hardly touch upon all you can do (i use a midi translator template to translate midi messages from my controller for all of my live sets).

in this simple case we will use the Bomes virtual ports to route Midi Messages to a DAW. here is how we configure this:

you can see it's quite simply a matter of connecting your virtual in with your virtual out.  

now let's put this into action:

1. make sure both your iphone and computer are on the same wireless network.
2. fire up your Pure Data midi controller template.  check the root window and make sure there are no error messages.
3. make sure bomes is running and configured (or midi yoke is configured)
4. launch TouchOSC on your iphone.  click on the network configuration.  you will see a screen that looks like this:

the host will be the IP of your computer (the wireless IP).  the outgoing port is the dumpOSC port you see in your pure data template (reference the pure data image above to see 8001).  the incoming port is what TouchOSC will receive midi messages on.  in the templates i am using, i am not receiving midi information back from the computer, but you can easily set this up in your templates.  for this example, i've used 9000.  the local IP address is the wireless IP of your iphone.
5. now that your network is set up, go back to the main TouchOSC screen and load your "Keys" layout.  if "Keys" is already selected in the layout section, just tap the upper right corner where it says "Done" to load the template.  you should then see your midi controller template on your iphone.

press C# on your iphone screen and you should see the following feedback on your pure data window:

we are successfully sending MIDI messages from our iphone to our PC!!

6. launch your DAW.  here is how to configure live, given the above scenario:

and here is what it looks like in sonar:

guess what?  that's it!!

you're now set to go....  your iphone will now work as any midi controller works...  

create some amazing UIs and share them with the rest of us!

feel free to ask any questions if you get stuck.

1 comment:

Micah said...

Great tutorial! I appreciate the post. Programming what I need into pd seems a bit daunting. Two questions for you: 1. Do you know of any libraries of Pure Data templates that are already made? 2. Would Line 6's Midi Mobilizer eliminate the need for the Pure Data connection?