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 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.

9 thoughts on “OSC on Android”

  1. Hey Martin

    My apologies, I’m a total noob with OSC, but I wanted to dive in now that my favorite sequencer is getting full OSC implementation.

    I’ve been trying to get this working on my g1 to transmit to max/msp using the CNMAT max external. I’ve verified that max can receive, but my android device is unable to send.

    I’m not getting any useful errors in eclipse, everything seems to be working but I’m not seeing anything in max.

    Is OSCLib compatible with CNMAT?

    Toss me an email if you don’t mind. I’d love to chat with you about this.

  2. I got it working!

    I made two noob mistakes.

    #1 I forgot the . at the end of the osc command.
    #2 The mac wanted to be on the wireless network, not the wired network.

    Now for the fun part.

  3. Does anyone know which sort of video files are supported? I keep in mind the Intuition only could dl 3gp utilizing opera mini. I downloaded the twist ap, maybe that is the issue? How can I watch videos from sites aside from youtube? Which file sorts? Normally I’m given the option of 3gp or mpeg4. Can’t get both to work. Thank you in your time! Rattling I want I was eligible for the improve to EVO!

  4. Martin, thanks for OSClib, your Android client works fine. As there is no TouchOSC client for Android I really have a need for sending OSC messages.

    @julien: works perfect for me on a HTC Desire. looks like you have to adapt IP and port address on your client&server?

    1. Glad its working. I’ll have to check if there’s a proper release of the slf4j-android library about and then maybe try and actually do something with OSC on my hero. :)

  5. Unfortunately, OSClib Android example doesn’t work on Honeycomb, since you can’t run blocking operations in the main UI thread.

    I tried to implement a solution based on AsyncTask (a task for connecting and another one for sending messages) but I’m unable to get it to work. Would be nice if someone wants to take a look at it too.

  6. Hi! I just used your awesome OSClib to create a little OSC Test Suite for Android!

    It seems that most people want to send OSC messages, but for this I wanted to implement an OSC server so your Android app can ACCEPT OSC messages from other apps or even other devices! My hope is to get more people implementing OSC servers to open up control of apps and games beyond the phone’s touchscreen and accelerometers, for example using a MIDI keyboard to play a synthesizer app on your phone, or even using sensors embedded in your clothes to control games/music/video, like the VJacket ( http://vjacket.com )

    It includes an updated example of receiving OSC messages in a different thread than the UI (this should solve Paulo Pires’ problem), as well as an OSC client test service. Please try it out and let me know how you like it!


Leave a Reply

Your email address will not be published. Required fields are marked *