flosc: Flash Open Sound Control

flosc is a Java server that can communicate with anything that uses the Open Sound Control protocol. This includes software audio synthesizers like Max/MSP, Reaktor, and SuperCollider, and hardware like Lemur and SmartController. It can also communicate with Macromedia Flash (versions 5 and later) using Flash’s XMLSocket feature.
flosc acts as a gateway between OSC and Flash, allowing messages to go in both directions. This enables many combinations of powerful, programmable platforms for high-quality animation, audio, video, and interactive production. flosc can accept simultaneous input from multiple OSC connections and Flash clients, and can broadcast messages to multiple Flash clients, but it does not do any routing. Think of it as a simple gateway or bridge between the generally UDP world of OSC and the TCP world of Flash XMLSockets.
Matt Wright accurately summarized flosc as:
“A standalone application written in Java that sends and receives OSC packets via UDP, translates bidirectionally between binary OSC packets and an XML encoding of OSC packets, and sends and receives XML entities via TCP in a way that’s compatible with Flash’s XMLSocket feature.”
That probably sounds a lot more complicated than it really is.
Download
This archive contains the .java and .class files for the flosc server, as well as an example Flash client. The code might be useful if you want to see how to write a recursive OSC packet parser in Java, or how to parse or create XML in Flash, or how to create a 4-byte boundary aligned array of bytes from objects in Java. Why reinvent the wheel? You can do anything you want with flosc and the source code… just don’t start selling it or blaming me for anything.
flosc-0.3.1.tar.gz
(All platforms – 56 KB)
Install
Put the files anywhere you like. Be sure you have a Java runtime environment version 1.1 or later installed. (All versions of OS X come with this, so that makes your life easy if you’re on a Mac.) Run the server like this:
java Gateway oscPort flashPort
where oscPort is the port on which you’d like flosc to receive OSC packets (the UDP port for it to listen on), and where flashPort is the port to which Flash clients will connect (the TCP port you’re using in Flash).
To learn how to send and receive OSC packets using your application of choice, see the application documentation. Start the server, connect your Flash client, and send some packets back and forth. Then, all you have to do is think of something interesting to do with all this technology.
FAQ
So how do you work this thing?
Try starting with this tutorial by Eric Socolofsky. (Thanks, Eric!)
Any other help?
Try the forum.
I’m getting a NoClassDefFoundError.
That’s not a question, but check your classpath.
Can I run flosc, a Flash movie, and my OSC application all on the same machine?
Yes. The only reason to run things on different machines is to balance the load and increase the amount of processing power you can use in each application. If you are running everything on the same machine, you should be able to use the loopback address, 127.0.0.1, as the IP address everywhere you need to supply an IP address. (This is the default as of Version 0.3)
Why does the server fail to start when I’m not connected to the internet?
If you’re on an OS 9 Macintosh, you need to make sure you have TCP/IP set so that it’s running all the time. (In the TCP/IP control panel, press the Options… button, select “Active”, uncheck “Load only when needed”, press OK.)
Does this work with SuperCollider 3?
Yup! Version 0.3.1 fixed a long-standing bug, and so now any messages you can encode in Flash will make it over to SC3 just fine.
Applications
People have actually used flosc to make real stuff. Really! Here’s proof:
Project Eclipse – Modular synthesis patch interface
Contemplace – Responsive environment
Space Jockey – Sound source positioning
Luminance – Interactive playground
And if that stuff’s not stuffy enough, here’s a paper: OpenSound Control: State of the Art 2003 [PDF] and a conference proceedings.
Credit
This project is inspired by work done with my friend Sam Torrisi. Thanks to Colin Moock and Derek Clayton for their examples of basic XMLSocket communication in Flash, and the design for the example Flash client. Thanks to Sean Rooney for taking flosc, improving it, generalizing it, and then sharing it back. Thanks to Jesse Gilbert for actually reading the comments in my code and reminding me that static is good sometimes. And, of course, we would be nowhere without Matt Wright and the CNMAT crew. Thanks to Dr. Toast for moving in with me so I would have to fix the bugs I was leaving open.
flosc includes code from the (now-defunct) Java Apache Project — see Bytes.java for more information. It also includes code written by Phil Scovis — see TcpServer.java for more information. Open source sure is really nice, don’t you think?
Related
Oscar is an OS X application that does OSC-to-Flash communication (that is, it translates UDP packets of OSC into TCP packets of XML-encoded data for connected Flash clients).
