Skip to content

Instantly share code, notes, and snippets.

@shks
Created June 19, 2020 17:21
Show Gist options
  • Save shks/711411b5ea6151c099d7ca29ff901a29 to your computer and use it in GitHub Desktop.
Save shks/711411b5ea6151c099d7ca29ff901a29 to your computer and use it in GitHub Desktop.
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