Created
March 27, 2012 21:09
-
-
Save jplattel/2220257 to your computer and use it in GitHub Desktop.
Zeo Raw Data to OSC
This file contains hidden or 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
# Imports | |
from ZeoRawData.BaseLink import BaseLink | |
from ZeoRawData.Parser import Parser | |
import OSC | |
def eventCallback(self, timestamp, version, event): | |
# For debugging | |
print event | |
def sliceCallback(slice): | |
# Bad Signal | |
if slice['BadSignal'] == True: | |
print 'Empty waveform... Bad signal' | |
elif slice['Waveform'] is not []: | |
for w in slice['Waveform']: | |
# Set OSC Message | |
m = OSC.OSCMessage() | |
m.setAddress("/zeo") | |
m.append(str(w)) | |
client.sendto(m,(osc_host, osc_port)) | |
# Initialize | |
port= "COM10" | |
link = BaseLink(port) | |
parser = Parser() | |
print "Zeo Connected..." | |
# Add the Parser to the BaseLink's callback | |
link.addCallback(parser.update) | |
print "Raw data input initialized..." | |
# Setting up OSC Client | |
client = OSC.OSCClient() | |
osc_host = '127.0.0.1' | |
osc_port = 9000 | |
print 'Setting up OSC...Port out: ' + str(osc_port) | |
# Add your callback functions | |
parser.addEventCallback(eventCallback) | |
parser.addSliceCallback(sliceCallback) | |
print 'Enabled callbacks' | |
# Start link | |
print "Start reading data:" | |
link.run() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment