Last active
January 20, 2017 10:09
-
-
Save shinybit/3d7e0fc7e62887ab48e931af1d4c0986 to your computer and use it in GitHub Desktop.
Sending OSC messages from Pythonista with pyOSC: http://bit.ly/1Vl8PCN
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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