OSC Library

The OSC (Open Sound Control) library supports communication with OSC enabled devices (e.g., smartphones, tablets, other computers, etc.).  To use it, you need following in your program:

As opposed to MIDI devices, which need to be physically connected (via wire) to your computer, OSC devices just need an Internet connection. This opens endless possibilities for interactive applications and installations.

The OscIn Class

OscIn objects receive incoming OSC messages from OSC devices (e.g., an OSC-enabled smartphone, or tablet).

Use the following function to create a OscIn object:

Function Description
OscIn( port ) Creates a new OscIn object to receive incoming messages from an OSC device (such as a smartphone, or tablet) at the given port.  The port number is an integer from 1024 to 65535 that is not being used by another program.

 

Once an OscIn object (e.g., oscIn) has been created, the following functions are available:

Function Description
oscIn.onInput( address, function ) When an OSC message with the given address arrives, call function.  OSC addresses look like a URL, e.g., “/first/second/third”.  The function should expect one parameter, the incoming OSC message.
oscIn.showMessages() Prints out incoming OSC messages. This is the default. Used to explore what OSC messages are generated by a device, so that they can be associated with callback functions.
oscIn.hideMessages() Stops printing out incoming OSC messages.

 

The OscOut Class

OscOut objects send OSC messages to devices (e.g., computers) that listen for incoming OSC events.  You could use a collection of OscIn and OscOut objects to synchronize (or share data between) two different programs on the same computer, or several computers used in an installation.  These computers do not have to be physically connected (only to be on the Internet).

Use the following function to create a OscOut object:

Function Description
OscOut( IPaddress, port ) Creates a new OscOut object to send messages to another OSC device (such as a smartphone, or tablet) at the given IPaddress (a string, e.g., “192.168.1.223″) and port (an int in the range 1024 to 65535).

 

Once an OscOut object (e.g., oscOut) has been created, the following functions are available:

Function Description
oscOut.sendMessage( address, arg1, arg2, … ) Sends out an OSC message with address and 0 or more arguments to the device listening.

For more information, see chapter 9.