OscIn
Receive OSC messages from another device.
OSC (Open Sound Control) is a way for programs and devices to send each other messages over a network. Creating an OscIn listens for messages on a port; use onInput() to call your own function whenever a message arrives at a given address.
When an OSC message arrives, any function registered for this message will be called and given the OscMessage as an argument.
Creating an OscIn
You can create an OscIn using the following functions:
OscIn()
OscIn(port)
| Parameter | Type | Default | Description |
|---|---|---|---|
port |
int |
57110 |
The port to listen on, a number from 1024 to 65535 that no other program is using. |
For example,
oscIn1.py
# oscIn1.py
#
# Demonstrates how to run some code when a particular OSC message arrives.
#
from osc import *
oscIn = OscIn( 57110 )
def simple(message):
print("Hello world!")
oscIn.onInput("/helloWorld", simple)
Functions
Once an OscIn oscin has been created, the following functions are available:
| Function | Description |
|---|---|
oscin.onInput(oscAddress, action) |
Set up a function to call when a message arrives at a given address. |
oscin.showMessages() |
Start printing incoming OSC messages to the console. |
oscin.hideMessages() |
Stop printing incoming OSC messages to the console. |