flosc : Flash OpenSound Control

flosc is a Java server that can communicate with anything that uses the OpenSound 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 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.

History

[7/26/2006] Is this thing still on? Well, there's a new forum if you want to talk about flosc. Thanks to Thijs for setting that up.

[7/19/2004] Version 0.3.1 released (bug fix). With the help of Dr. Toast, I finally got around to figuring out what was going on with flosc and SC3. Apparently I was never padding strings out to 4-byte boundaries, which would corrupt the numeric (or other argument) data. I have no idea how this code ever worked for any of us in the past. I'm glad to have that fixed, because the fix has prompted me to update this web site, notably including the fine flosc tutorial by Eric Socolofsky. One final note, there is an Open Sound Control conference coming up on July 30 in Berkeley and I'll be talking about flosc and a new OSC-in-XML standard (look for another update soon as I implement it).

[10/19/2003] Security Update: Flash Player 7 works fine as a standalone application, since the security model is not applied to locally-running content. However, using the test movie command from within the Flash authoring tool probably won't work correctly. For more details, see thie article by Deneb. Note that you can use /etc/hosts or the equivalent to assign domain names to IP addresses for your local machine.

[9/29/2003] There appears to be an issue with flosc and the Flash Player 7, likely related to the changes made to the security model. Until this issue is resolved, you should use a version 6 or earlier player.

[5/17/2003] Graham Wakefield has contributed a compiled application version of Version 0.3 for OS 9.

[5/13/2003] Version 0.3 released. Performance improvements due to static creation of a UDP socket for sending OSC and no more printing of debug statements to stdout. Also changed the default IP addresses in the flash movie to be 127.0.0.1, since I assume the simplest configuration is with everything running on localhost. Tested on OS X using the precompiled sendOSC and dumpOSC. No more different archive formats for Mac and Windows... if you're on Windows, install cygwin.

[4/11/2003] Updated the MIDI-to-OSC application that Sean Rooney created, he says there was a bug in the previous version. Also just started exchanging email with Matt Wright about perhaps standardizing the XML representation of OSC, and pulling flosc apart into a standalone Java OSC server and a TCP/XML component. We shall see what comes of this.

[3/9/2003] Added a new example application created by Sean Rooney. Added a section for answering FAQs. Made this page look a little nicer.

[3/23/2002] Version 0.2 released. Adds support for Flash-to-OSC communication, including a DTD describing how XML-encoded OSC packets should be formed, Flash and server parsing of XML-encoded OSC, and Flash creation of XML-encoded OSC.

[3/7/2002] Version 0.11 released. Adds support for SuperCollider-style arrays. Still no bidirectional communication, but all that needs to be done is a minimal XML parser to process the data coming from Flash. The OSC-sending code is in the archive, but not hooked up to anything yet. Next version will have a proper DTD.

[3/3/2002] Version 0.1 released. This version only allows OSC-to-Flash communication.

Download

Current Version

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)

Previous versions are available, but are probably only useful for historical purposes.

Examples

We have no examples to recommend at the moment. The files that used to be here were just confusing people because they relied on SuperCollider 2 and Flash MX. Most people today are using SC3 and MX2, so the examples didn't work very well, causing people to complain that flosc was broken. So, no more out-of-date examples. If you have any files you'd like to share, please feel free to email me.

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 where flosc will 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 or the OpenSound Control site. 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 a Macintosh (pre-OS X), 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.

Feedback

I would love to know what you think of flosc, how you use it, and how it could be improved. And, of course, please let me know about any bugs you find.

ben [at] benchun [dot] net

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 nice, don't you think?