The "Open Sound Control" protocol is specifically designed to control multimedia installations in a local area network or over the internet. OSC was original designed to for the data to transported local and over the internet via UDP, but it some software is setup to use OSC over alternative communication protocols.
Due to its popularity, OSC is often the easiest way to get two or more applications, computers or devices to talk to each other.
Tools
- OSCulator - Routing Application for OSX.
- TouchOSC - OSC Interfaces for iPad und iPhone.
- Resolume - VJ Software with built in OSC interface
Processing Examples
If values are to be passed from Processing to other applications (e.g. Max MSP) or if values from these programs are to be received in Processing, we can use the Processing Library oscP5 (http://www.sojamo.de/libraries/oscP5/ ). This must also be downloaded and then placed in the library folder of Processing.
In order to send values to another computer via OSC, we must first import the library:
import oscP5.*; // oscP5 Library import import netP5.*; // netP5 Library import OscP5 oscP5; // Define osc object NetAddress remoteLocation; // Define goal address
In the next step we initialise the library and set the target address:
void setup() { oscP5 = new OscP5(this, 12000); // Start the library and wait for incoming messages on port 12000 remoteLocation = new NetAddress("172.31.224.73", 12000); // The IP address and port of the recipient }
Now all we have to do is create messages and send them to the destination address:
void mousePressed() { OscMessage msg = new OscMessage("/test"); // new message "/test" as Adresse pattern msg.add(123); // send a simple value oscP5.send(msg, remoteLocation); // Send the message }
To receive messages we can add the following code:
void oscEvent(OscMessage msg) { println("### new message"); println("AddrPattern: " + msg.addrPattern()); // Output of the address pattern println("TypeTag: " + msg.typetag()); // Output of the Type-Tag // Adresse pattern test if(msg.addrPattern().equals("/test")) { // Output the number sent println(msg.get(0).intValue()); } }
P5js Examples
Currently it's not possible to use UDP communication from javascript running in the browser. However, we can use websocket.
void oscEvent(OscMessage msg) { println("### Neue Nachricht"); println("AddrPattern: " + msg.addrPattern()); // Ausgeben des Adress-Muster println("TypeTag: " + msg.typetag()); // Ausgeben des Type-Tag // Adress-Muster überprüfen if(msg.addrPattern().equals("/test")) { // Mitgesendete Zahl ausgeben println(msg.get(0).intValue()); } }