Skip to content

Instantly share code, notes, and snippets.

@shinybit
Last active January 20, 2017 10:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shinybit/3d7e0fc7e62887ab48e931af1d4c0986 to your computer and use it in GitHub Desktop.
Save shinybit/3d7e0fc7e62887ab48e931af1d4c0986 to your computer and use it in GitHub Desktop.
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