OSC on Android

I just bought myself a HTC Hero so im starting to learn all the Android development stuff.

So the first thing i’ve tried is to see how easy it is to get my OSCLib stuff working. There isnt a lot to the actual library itself as most of the hard work is handled by Apache Mina. I started a new Android project in eclipse and just tried to send a simple OSC message to a test server on my local machine. It didnt work, the dalvik VM told me I had a verify error. I eventually narrowed this down to the SLF4J library. At this stage I had no clue about how to fix it so back to google to see if someone else had done the hardwork. :)

I found this thread where Thorsten Möller says he actually has a version of slf4j but its not on the main site yet, just in his git repo. So after a clone of that and a run of maven I had a shiny new slf4j-android.jar which I’ve upload to my site here.

I added that jar to the dependencies of my OscAndroDemo test project and it worked. Easy. :)

All the source is available from the OSCLib assembla project. The main library is in /trunk/java, its an eclipse project and in there you can run the OSCServer class for testing. It’ll spit out some info to stdout when it receives a message. The android project is in /trunk/android/AndrOscDemo which you can check out from SVN directly into eclipse.

The demo just connects to 10.0.2.2:10000 and sends a single message. The next stage is to try and do some interesting stuff with the various sensors like the accelerometer and see if any issues arrive once I start sending lots of messages.

OSC – Open Sound Control

For some reason, MIDI isnt dead yet, although it is indeed ‘ubiquitous and lightweight’ that doesn’t mean it should stick around. For some tasks its fine, but its definitely starting to show its age. One of the alternatives for communication between audio / video software and devices is Open Sound Control – OSC.

Im not going to go into a deep discussion of MIDI vs. OSC at this point, there are of course some benefits to MIDI which OSC should deal with in some way (e.g. a standardised namespace for representing MIDI semantics, or a discovery mechanism for that namespace..)..anyway, I just want to let you know that I’ve been working on some OSC related stuff to make using it easier from both Actionscript 3 and Max/MSP.

First up is OSCLib, this is intended as a low level set of OSC libraries which you can use in other applications. Actionscript 3 doesnt have UDP, only HTTP sockets whereas most OSC implementations (e.g. Reaktor, Bidule) are UDP based although one notable exception is SuperCollider which supports both. So to help bridge the gap there are java implementations for both HTTP and UDP clients and servers (well, the UDP server is currently missing but should be done in a day or two..)

For Max/MSP there is an MXJ object which wraps the HTTP server so you can send messages from a Flash / Flex client directly to Max/MSP.

There is some documentation on the project wiki pages for getting your dev environment setup and also a Flash / Max demo you can try out.

As a side note if anyone has a Korg Kontrol49 then i’ve also got a project based on OSCLib for working with the Kontrol49 in native mode : KontrolTools. This allows you to have full control of the lights and text displays via OSC as well as generate OSC message from all the knobs, sliders and buttons.