Skip to content

Instantly share code, notes, and snippets.

@shks

shks/OSC-Python.py

Created Jun 19, 2020
Embed
What would you like to do?
Touchdesigner - python communication via OSC
#python
'''
setup instruction
for Install pythonosc
pip install python-osc
'''
from pythonosc import dispatcher
from pythonosc import osc_server
from pythonosc import udp_client
def messege_handler(unused_addr, *p):
try:
print(p)
client.send_message("/message_echo", p)
except ValueError: pass
dispatcher = dispatcher.Dispatcher()
dispatcher.map("/message", messege_handler)
server = osc_server.ThreadingOSCUDPServer(("127.0.0.1", 5005), dispatcher)
print("Serving on {}".format(server.server_address))
client = udp_client.SimpleUDPClient("127.0.0.1", 5006)
server.serve_forever()
n = op('oscout1')
n.sendOSC('/message',['something', 9999])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment