Simple Python OSC:
Code:
import socket, struct
def OSCBinary(*l):
Binary = b""
for e in l:
t = type(e)
if t is bytes:
b = e
b += b"\0" * (4 - len(b) % 4)
elif t is str:
b = e.encode("utf-8")
b += b"\0" * (4 - len(b) % 4)
elif t is int:
b = struct.pack(">i", e)
elif t is float:
b = struct.pack(">f", e)
Binary += b
return Binary
def OSCSendAction(Address, Action):
if type(Action) is int:
Binary = OSCBinary("/action", ",i", Action)
else:
Binary = OSCBinary("/action/str", ",s", Action)
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.sendto(Binary, Address)
s.close()
OSCSendAction(("localhost", 8000), 40007) # Reaper About
OSCSendAction(("localhost", 8000), "_RS9f248dbb3abdc0abac1b5182342297de37ef72d2") # String CommandID