OSC to Websockets using node.js

The last weeks I have improved the Simplecanvas app so now it has more features, the main one is that now you are able to share your creations with other people. I am also improving the API so it has more features and makes it easy to animate objects through time.

The only missing thing is the input, I thought it would be nice to be able to interact with the creation through some kind of simple interface. The only supported input is the mouse coordinates which is nice to do some effects but not enought to synchronize with other people.

On that line my friend Graham, an experienced music live-coder, suggested me to add OSC support so he can send me messages from his live coding sessions (using chuck) so I can use them to synchronize the beat in my animations.

I already have WebSockets support for other projects like SharedCanvas using a node.js server (without socket.io, I don’t like that library, it wants to reach so many cases making it hard to work with), the problem is that WebSockets doesn’t allow to connect to any kind of server, only to a websockets server, so I thought of using a bridge server between OSC and WebSockets, I found OSC-web by Vilson Vieira (@aut0mata) but it didnt worked, the version on his website seems to be coded to an old nodejs version, so I decided to make my own using the same library he used, node-osc.

The code is pretty simple, you can download it from here: OSCBridge.js I have only tested it under Ubuntu, but the Windows or OSX version should work if you already have nodejs working with other modules.

To install you will need to install this modules, you can use NPM (be sure to have python installed as it uses it to compile the modules):

npm install node-osc
npm install faye-websocket

To run you write:

node oscbridge.js -port 4343

The port you specify is for the WebSocket, the OSC server will  be host in that port plus one (4344)

Right now it only works in one direction OSC -> WebSockets but I plant to expand it so I can send OSC messages from Javascript.

You can try it using this example:



5 Responses to “OSC to Websockets using node.js”

  1. peripecio Says:

    OK! It works! Thanks for sharing

  2. Florian Says:

    Thanks for shring the OSCBridge.js example. I got it to work. Would you mind sharing a little code example how to send an OSC message from the browser after connecting with the server?
    Thanks, Florian

  3. vb078 Says:

    Great job with all needed ressources!
    I work on processing right now.
    I use – oscP5bundle by andreas schlegel
    When I send to the right port some osc message with it all is working great, socket.io recieves the message…
    But, I cant figure how to clear a message with node, to reset the message when processing (oscP5bundle)
    stop sending…
    Do you have some wonderfull ideas ? 🙂
    Thx again

  4. vb078 Says:

    I find my way using -v, all working…
    but, i cant find how to open the client.
    I try app.html but doesnt recieve any thing.
    Am on firefox last version
    Thank you

  5. tamat Says:

    Sorry vb078 but it is a very old code that is no longer working, but there are many new OSC libraries for node.js in the repository of node. Check them out.

Leave a Reply

three + = 8