I checked in code this week to support Open Sound Control for Lily- it consists of two pieces: a Java component that implements methods from the JavaOSC library and two Javascript externals (oscsend & oscreceive) that use the OSC service.
Initially I assumed OSC could be done entirely in Javascript using nsISocketTransport- once I got into it, I quickly realized mozilla sockets don't support UDP. (incidentally, I bumped into this dormant project which has created UDP sockets, but apparently there are Mac build issues) Not being able to do it in JS meant I'd have to write an XPCOM component- something I'd manage to avoid so far. After a little poking around on the web, I decided against coding it in C++ simply because maintaining 3 separate builds (4 actually since the Mac Gecko SDK isn't universal) seemed too much like work. I looked at Python for about a second and then came around to Java.
Mozilla's 'official' project supporting Java components- JavaXPCOM- seems geared to embedding rather than extensions, but fortunately I stumbled across this from the folks at SIMILE which demonstrates how to load Java classes and call methods from extension code. Great, except I also needed to be able call into Javascript from Java, something the sample code doesn't do. After spending a silly amount of time trying to make it work with LiveConnect, I bagged it and just used sockets to do the Java to JavaScript communication, which works but is, like, totally suboptimal.
Having OSC opens up new ways of talking to Lily- with a helper Max patch, I'm able to use various game controllers as well as my new 40h. Also, now that I have OSC working, I'm planning on using what I've learned about Java components to add support for other fun stuff- serial access, Applescript, etc. I also have a couple of nice OSC Lily demos in the works I'll post here soon.
Comments (1)
Hello, I just came across this.. I recently developed an OSC component for XPCOM so that people could do OSC using the Mozilla framework. It's quite raw, but it might be helpful to you. Cheers.
http://www.create.ucsb.edu/pipermail/osc_dev/2007-April/001215.html
Posted by Steve | May 25, 2007 2:18 PM
Posted on May 25, 2007 14:18