OSC
endif ?>OSC (OpenSoundControl, http://opensoundcontrol.org/) is a communication protocol which allows you to share (typically music performance) data in real-time over a network. OSC is similar to MIDI and allows musical instruments, controllers and multimedia devices but also software to communicate via a standard home or studio network (TCP/IP, ethernet) or via the internet.
Some NodeBox libraries already use OSC (wiiNode, Reactivivision) but we thought it might be useful as a library in itself.
Download
OSC.zip (1210KB ) Last updated for NodeBox 1.9.4 Licensed under the GPL Authors: Daniel Holth, Clinton McChesney, ixi-software Examples/EMG |
Documentation
How to get the library running
Put the "osc" library folder in the download in the same folder as your script so NodeBox can find the library. You can also put it in ~/Library/Application Support/NodeBox/.
osc = ximport("osc")
Have a look at test.py to see a simple 'pure-data talks to nodebox and back' example.
Sending data
Before sending or receiving data OSC should be initialized. The process initializes the callback manager and the out-socket.
osc.init()
Sending data over osc has different possibilities. You can send a single message or a bundle that stores several messages.
A single message:
message = osc.createBinaryMsg(osc_address, data_list)
osc.sendOSC(message, ip_address, port)
or in one line:
osc.sendMsg(osc_address, data_list, ip_address, port)
As for bundles, the above can be used because the data sent is a list that can contain more than one message. There are options to create and send a bundle in a different way.
Methods for making a bundle, adding items to it and sending it:
bundle = osc.createBundle()
osc.appendToBundle(bundle, osc_address, data_list)
osc.sendBundle(bundle, ip_address, port)
Receiving data
To receive data over OSC an in-socket should be set up.
in_socket = osc.createListener(ip_address, port)
The in-socket can be used to get incoming OSC to send it to the callback manager.
osc.getOSC(in_socket)
A final command can bind OSC addresses with commands in the sketch.
osc.bind(nodebox_command, osc_address)
A lot of possibilities
OSC has been implemented in a variety of software. The library contains a few examples in Pure Data and Processing but many other applications like Max, Quartz Composer, Bidule have OSC-implementations. For a full list go to this page.
- test.py + test.pd illustrates the two way communication between NodeBox and Pure Data.
- fft.py + fft.pd visualizes the sound spectrum. (talk to it)
- scratcher.py + scratcher.pd are ... what could it be? (sample by DJ Craze)
- fftTOmovStepOne.py and Two are sketches to produce crystal clear FFT-animation.
The code needed for the Processing script is at the bottom within the source.