Open Sound Control (OSC) Networking

rcp.osc

Objects related to OSC messaging.

class rcp.osc.QtOSCListener(*args: Any, **kwargs: Any)[source]

Object to manage a OSC network input. This uses a Qt QUdpSocket to receive messages from the main Qt event loop and a pythonosc dispatcher to decode OSC messages and distribute them to callbacks. Messages are delivered on the main thread. This requires a pythonosc version of at least 1.7.0 so the dispatcher can be used in this way.

Parameters:
  • port – optional UDP port number to which to receive, defaults to 3761

  • host – optional hostname or IP address to which to receive, defaults to localhost

map_handler(address, callback)[source]

Add an address template string to the dispatch map.

message_received()[source]

Callback attached to the port readyRead signal to process incoming UDP packets.

open_receiver()[source]

Create a UDP socket, bind it to the desired port, and set up callbacks to process messages upon receipt. This may be called again after the port address has changed and will create a new socket.

set_OSC_port(address, portnum)[source]

Called to configure a new network address. If the port is already open it is closed and a new port opened with the new address.

unknown_message(msgaddr, *args)[source]

Default handler for unrecognized OSC messages.

class rcp.osc.QtOSCSender(*args: Any, **kwargs: Any)[source]

Object to manage a OSC network output. This is a thin wrapper around the pythonosc SimpleUDPClient to allow this object to close and reopen the port at will while retaining its identity in the application.

Parameters:
  • port – optional UDP port number to which to send, defaults to 3762

  • host – optional hostname or IP address to which to send, defaults to localhost

open_sender()[source]

Create a UDP client with the chosen destination address. This may be called again after the port address has changed and will create a new socket.

send(address, *args)[source]

Send a UDP packet containing a single OSC message to the predesignated host address and UDP port number.

Parameters:
  • address – an OSC ‘address’ string beginning with a forward slash

  • args – optional arguments, which must be primitive types convertible to OSC message data types

set_OSC_port(address, portnum)[source]

Called to configure a new destination network address. If the port is already open it is closed and a new port opened with the new address.