Skip to content

Instantly share code, notes, and snippets.

@shinybit

shinybit/osc_client.py

Last active Jan 20, 2017
Embed
What would you like to do?
Sending OSC messages from Pythonista with pyOSC: http://bit.ly/1Vl8PCN
#!/usr/bin/env python
# Get pyOSC here: https://trac.v2.nl/wiki/pyOSC
# The GitHub-hosted version of pyOSC is for Python 3 which isn't supported by Pythonista at the moment
from OSC import OSCClient, OSCMessage
client = OSCClient()
client.connect(("192.168.43.120", 8000))
msg = OSCMessage("/msg/notes")
msg.append([50, 60])
client.send(msg)
msg.clearData();
msg.append(["C3", 127])
client.send(msg)
client.send(OSCMessage("/quit"))
#!/usr/bin/env python
# Get pyOSC here: https://trac.v2.nl/wiki/pyOSC
# The GitHub-hosted version of pyOSC is for Python 3 which isn't supported by Pythonista at the moment
from OSC import OSCServer
server = OSCServer(("192.168.43.120", 8000))
server.timeout = 0
print "OSC Sever started. Press Ctrl-C to stop."
def handler(addr, tags, data, client_address):
s = "Message '%s' from %s: " % (addr, client_address) + str(data)
print s
def quit_handler(addr, tags, data, client_address):
print "OSC Server quit."
server.close()
server.addMsgHandler('/msg/notes', handler)
server.addMsgHandler('/quit', quit_handler)
server.serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.