First Steps¶
This is a quick guide to get you started with PyOSC, you should follow the API docs and examples for more detailed information on how to use the library.
Sending Your First OSC Message¶
To send your first OSC message using PyOSC, you can use the following example code:
from pyosc import Peer, OSCMessage, OSCModes, OSCFraming, OSCInt, OSCString
peer = Peer(
"127.0.0.1",
3032,
mode=OSCModes.TCP,
framing=OSCFraming.OSC11,
)
message = OSCMessage(
address="/test/message",
args=(
OSCInt(value=42),
OSCString(value="Hello_World!"),
)
)
peer.send_message(message)
Peer object, using the TCP mode, and framing from OSC version 1.1. It then constructs a OSCMessage with the address /test/message and two arguments:
- An integer with the value
42 - A string with the value
Hello_World!
Finally, it sends the message using the send_message method, of the Peer object.