Skip to content

Instantly share code, notes, and snippets.

@ajinkyapuar
Forked from shks/OSC-Python.py
Created October 17, 2022 07:27
Show Gist options
  • Save ajinkyapuar/0123f75676cf497c43e9f974aae92e26 to your computer and use it in GitHub Desktop.
Save ajinkyapuar/0123f75676cf497c43e9f974aae92e26 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