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.


Incoming OSC messages

When an OSC message arrives, any function registered for this message will be called (see oscIn.onInput() above).

This function will be given the OSC message as an argument.  This argument, message, has two functions:

Function Description
message.getAddress() Returns the message’s OSC address as a string, e.g., “/first/second/third”.
message.getArguments() Returns the message’s OSC arguments as a list.

For example, this program demonstrates how to access the information stored in an incoming OSC message.  It registers a function to be called for any incoming OSC message (i.e.,”/.*”). This function outputs the actual address and arguments stored in the OSC message.

# printOSCmessage.py
# Demonstrates how to print (access) the information in an OSC message.

from osc import *

oscIn = OscIn( 57110 )

def echo(message):
   address = message.getAddress()
   args = message.getArguments()
   print address, args

oscIn.onInput("/.*", echo)