本文整理汇总了Python中OSC.decodeOSC方法的典型用法代码示例。如果您正苦于以下问题:Python OSC.decodeOSC方法的具体用法?Python OSC.decodeOSC怎么用?Python OSC.decodeOSC使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OSC
的用法示例。
在下文中一共展示了OSC.decodeOSC方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: import OSC [as 别名]
# 或者: from OSC import decodeOSC [as 别名]
def main(self):
""" Main loop """
while 1:
if self.dataReady("control"):
msg = self.recv("control")
if (isinstance(msg, producerFinished) or
isinstance(cmsg, shutdownMicroprocess)):
self.send(msg, "signal")
break
if self.dataReady("inbox"):
data = self.recv("inbox")
if self.index is None:
decoded = OSC.decodeOSC(data)
# Send decoded data as (address, [arguments], timetag) tuple
self.send((decoded[2][0], decoded[2][2:], decoded[1]),
"outbox")
else:
decoded = OSC.decodeOSC(data[self.index])
data = list(data)
data[self.index] = (decoded[2][0], decoded[2][2:],
decoded[1])
self.send(data, "outbox")
if not self.anyReady():
self.pause()
yield 1
示例2: chew_data
# 需要导入模块: import OSC [as 别名]
# 或者: from OSC import decodeOSC [as 别名]
def chew_data(host, port):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.settimeout(0.05) # prevent blender from getting stuck if socket hangs
s.bind((host, port))
raw,addr = s.recvfrom(1024)
o = OSC.decodeOSC(raw)
return o
示例3: process_metatone_message
# 需要导入模块: import OSC [as 别名]
# 或者: from OSC import decodeOSC [as 别名]
def process_metatone_message(self, handler, time, packet):
"""
Function to decode an OSC formatted string and then process it
according to its address. Sends processed messages directly
to the metatone_classifier module's message handling functions.
"""
message = OSC.decodeOSC(packet)
try:
if "/metatone/touch/ended" in message[0]:
self.classifier.handle_client_message(message[0], message[1][1:], message[2:], FAKE_OSC_SOURCE)
elif "/metatone/touch" in message[0]:
self.classifier.handle_client_message(message[0], message[1][1:], message[2:], FAKE_OSC_SOURCE)
elif "/metatone/switch" in message[0]:
self.classifier.handle_client_message(message[0], message[1][1:], message[2:], FAKE_OSC_SOURCE)
elif "/metatone/online" in message[0]:
self.classifier.handle_client_message(message[0], message[1][1:], message[2:], FAKE_OSC_SOURCE)
handler.send_osc("/metatone/classifier/hello", [])
handler.deviceID = message[2]
handler.app = message[3]
elif "/metatone/offline" in message[0]:
self.classifier.handle_client_message(message[0], message[1][1:], message[2:], FAKE_OSC_SOURCE)
elif "/metatone/acceleration" in message[0]:
self.classifier.handle_client_message(message[0], message[1][1:], message[2:], FAKE_OSC_SOURCE)
elif "/metatone/app" in message[0]:
self.classifier.handle_client_message(message[0], message[1][1:], message[2:], FAKE_OSC_SOURCE)
elif "/metatone/targetgesture" in message[0]:
self.classifier.handle_client_message(message[0], message[1][1:], message[2:], FAKE_OSC_SOURCE)
else:
print("Got an unknown message! Address was: " + message[0])
print("Time was: " + str(time))
print(u'Raw Message Data: {}'.format(packet))
except():
print("Message did not decode to a non-empty list.")
示例4: heartbeat
# 需要导入模块: import OSC [as 别名]
# 或者: from OSC import decodeOSC [as 别名]
def heartbeat(add, tags, stuff, source):
global sw1
cpu = psutil.cpu_percent()
if sw1 == 1:
# print "HEARTBEAT RECIEVED!"
decoded = OSC.decodeOSC(stuff[0])
# supercollider CPU usage and UGens printout
cprint("CPU %/Number of Sounds: " + str(cpu) + "/" + str(decoded[3]), "red", attrs=["dark"])
# scaling CPU values
cpufloat = float(cpu)
# print decoded[7]
# ready the osc message
oscmsg = OSC.OSCMessage()
# determine which heartbeat to send
if cpufloat < 2.0:
oscmsg.setAddress("/heartbeat/faint")
elif cpufloat < 6.0:
oscmsg.setAddress("/heartbeat/weak")
elif cpufloat < 10.0:
oscmsg.setAddress("/heartbeat/medium")
elif cpufloat < 20.0:
oscmsg.setAddress("/heartbeat/strong")
elif cpufloat < 30.0:
oscmsg.setAddress("/heartbeat/heavy")
else:
oscmsg.setAddress("/heartbeat/intense")
# adding the CPU usage value to the message, this can be mapped later.
oscmsg.append(cpufloat)
qlcclient.send(oscmsg)
# sending CPU information back to SuperCollider
oscmsg = OSC.OSCMessage()
oscmsg.setAddress("/cpuinfo")
oscmsg.append(cpufloat)
scclient.send(oscmsg)
示例5: heartbeat
# 需要导入模块: import OSC [as 别名]
# 或者: from OSC import decodeOSC [as 别名]
def heartbeat(add, tags, stuff, source):
# print "HEARTBEAT RECIEVED!"
decoded = OSC.decodeOSC(stuff[0])
#supercollider CPU usage and UGens printout
print "SuperCollider CPU usage: "+str(decoded[7])+" Number of synths: "+str(decoded[3])
# scaling CPU values
scaled = int(interp(decoded[7],[0.0,40.0],[20,255]))
#print decoded[7]
# ready the osc message
oscmsg = OSC.OSCMessage()
#determine which heartbeat to send
if float(decoded[7]) < 2.0:
oscmsg.setAddress("/heartbeat/faint")
print "faint"
elif decoded[7] < 6.0:
oscmsg.setAddress("/heartbeat/weak")
print "weak"
elif decoded[7] < 10.0:
oscmsg.setAddress("/heartbeat/medium")
print "medium"
elif decoded[7] < 20.0:
oscmsg.setAddress("/heartbeat/strong")
print "strong"
elif decoded[7] < 30.0:
oscmsg.setAddress("/heartbeat/heavy")
print "heavy"
else:
oscmsg.setAddress("/heartbeat/intense")
print "intense"
# adding the CPU usage value to the message, this can be mapped later.
oscmsg.append(scaled)
c.send(oscmsg)
示例6: inductionmics
# 需要导入模块: import OSC [as 别名]
# 或者: from OSC import decodeOSC [as 别名]
def inductionmics(add, tags, stuff, source):
global sw1
global sw2
global inductioniter
# check if the switch is on, this is the same switch that controls the inducton light/sound
if sw2 == 1:
# this should only be displayed if the 'information' switch (switch 1) is on
if sw1 == 1:
# decoded OSC message, this needs to be done to the whole message and then
# the goodies need to be parsed out because OSC and arrays don't mix well
# indices 5, 6 and 7 of the 'stuff' contains hi/mid/low figures
decoded = OSC.decodeOSC(stuff[0])
# TODO: Sort this out. Print this every ten times this function is run
if inductioniter % 30 == 0:
cprint(
"Induction Power: Low - "
+ str(round(decoded[4], 3))
+ " Mid - "
+ str(round(decoded[5], 3))
+ " Hi - "
+ str(round(decoded[6], 3)),
"cyan",
attrs=["dark"],
)
inductioniter = inductioniter + 1
示例7: heartbeat
# 需要导入模块: import OSC [as 别名]
# 或者: from OSC import decodeOSC [as 别名]
def heartbeat(add, tags, stuff, source):
global sw1
if sw1 == 1:
# print "HEARTBEAT RECIEVED!"
decoded = OSC.decodeOSC(stuff[0])
#supercollider CPU usage and UGens printout
print "Sound CPU/Synths heartbeat: "+str(round(decoded[7],4))+"/"+str(decoded[3])
# scaling CPU values
scaled = int(interp(decoded[7],[0.0,40.0],[20,255]))
#print decoded[7]
# ready the osc message
oscmsg = OSC.OSCMessage()
#determine which heartbeat to send
if float(decoded[7]) < 2.0:
oscmsg.setAddress("/heartbeat/faint")
elif decoded[7] < 6.0:
oscmsg.setAddress("/heartbeat/weak")
elif decoded[7] < 10.0:
oscmsg.setAddress("/heartbeat/medium")
elif decoded[7] < 20.0:
oscmsg.setAddress("/heartbeat/strong")
elif decoded[7] < 30.0:
oscmsg.setAddress("/heartbeat/heavy")
else:
oscmsg.setAddress("/heartbeat/intense")
# adding the CPU usage value to the message, this can be mapped later.
oscmsg.append(scaled)
qlcclient.send(oscmsg)
示例8: inductionmics
# 需要导入模块: import OSC [as 别名]
# 或者: from OSC import decodeOSC [as 别名]
def inductionmics(add,tags,stuff,source):
global sw2
if sw2 == 1:
# decoded OSC message, this needs to be done to the whole message and then
# the goodies need to be parsed out because OSC and arrays don't mix well
decoded = OSC.decodeOSC(stuff[0])
#TODO: Sort this out. Print this every ten times this function is run
print "Induction Power: Low - "+str(round(decoded[4],3))+" Mid - "+str(round(decoded[5],3))+" Hi - "+str(round(decoded[6],3))
示例9: receiveOSC
# 需要导入模块: import OSC [as 别名]
# 或者: from OSC import decodeOSC [as 别名]
def receiveOSC(controller):
try:
raw_data = gl.socket.recv(BUFFER_SIZE)
data = OSC.decodeOSC(raw_data)
print(data)
except socket.timeout:
pass
示例10: inductionmics
# 需要导入模块: import OSC [as 别名]
# 或者: from OSC import decodeOSC [as 别名]
def inductionmics(add,tags,stuff,source):
global sw1
global sw2
# check if the switch is on, this is the same switch that controls the inducton light/sound
if sw2 == 1:
# this should only be displayed if the 'information' switch (switch 1) is on
if sw1 == 1:
# decoded OSC message, this needs to be done to the whole message and then
# the goodies need to be parsed out because OSC and arrays don't mix well
decoded = OSC.decodeOSC(stuff[0])
#TODO: Sort this out. Print this every ten times this function is run
print "Induction Power: Low - "+str(round(decoded[4],3))+" Mid - "+str(round(decoded[5],3))+" Hi - "+str(round(decoded[6],3))
示例11: main
# 需要导入模块: import OSC [as 别名]
# 或者: from OSC import decodeOSC [as 别名]
def main():
# Set init
ip = '127.0.0.1' ### escucha a routerOSC.pd
port = 8888
data = 0
# Get controller and owner
controller = GameLogic.getCurrentController()
owner = controller.owner
# Connect Blender only one time
if not owner['connected']:
owner['connected'] = True
print ("Blender Connected Ori")
GameLogic.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
GameLogic.socket.bind((ip, port))
GameLogic.socket.setblocking(0)
GameLogic.socket.settimeout(0.02)
# If Blender connected, get osc
else:
# Get hand wii osc from pd
data = receive_osc(data, port)
if data != 0:
d = OSC.decodeOSC(data)
print(d)
'''if d[2][8] == "/ori":
ori,ox,oz =d[2][9], d[2][10], d[2][11]
scn = bge.logic.getCurrentScene()
player = scn.objects["player"]
player['ori'] = ori
if d[2][12] == "/norte":
nx,ny =d[2][13],d[2][14]
scn = bge.logic.getCurrentScene()
player = scn.objects["player"]
player['tracker_n'] = nx,ny
# solo si hay 2 kinects!!!!!!
if d[2][15] == "/sur":
sx,sy =d[2][16],d[2][17]
scn = bge.logic.getCurrentScene()
player = scn.objects["player"]
player['tracker_s'] = sx,sy '''
if d[0] == "/norte":
nx,ny =d[2],d[3]
print(nx,ny)
scn = bge.logic.getCurrentScene()
player = scn.objects["player"]
player['tracker_n'] = nx,ny
示例12: heartbeat
# 需要导入模块: import OSC [as 别名]
# 或者: from OSC import decodeOSC [as 别名]
def heartbeat(add, tags, stuff, source):
# print "HEARTBEAT RECIEVED!"
decoded = OSC.decodeOSC(stuff[0])
#supercollider CPU usage and UGens printout
print "SuperCollider CPU usage: "+str(decoded[7])+" Number of synths: "+str(decoded[3])
# scaling CPU values
scaled = int(interp(decoded[7],[0.0,40.0],[20,255]))
print scaled
# sending heartbeat tick to QLC
oscmsg = OSC.OSCMessage()
oscmsg.setAddress("/heartbeat/on")
# adding the CPU usage value to the message, this can be mapped later.
oscmsg.append(scaled)
c.send(oscmsg)
示例13: decode
# 需要导入模块: import OSC [as 别名]
# 或者: from OSC import decodeOSC [as 别名]
def decode(data):
"""Converts a typetagged OSC message to a Python list.
modified for supercollider-specific messages.
"""
table = { "i":OSC.readInt,
"f":OSC.readFloat,
"s":OSC.readString,
"b":OSC.readBlob,
"d":OSC.readDouble}
decoded = []
address, rest = OSC.readString(data)
typetags = ""
if address == "#bundle":
time, rest = OSC.readLong(rest)
decoded.append(address)
decoded.append(time)
while len(rest)>0:
length, rest = OSC.readInt(rest)
decoded.append(OSC.decodeOSC(rest[:length]))
rest = rest[length:]
elif len(rest) > 0:
typetags, rest = OSC.readString(rest)
decoded.append(address)
decoded.append(typetags)
if(typetags[0] == ","):
for tag in typetags[1:]:
try:
value, rest = table[tag](rest)
decoded.append(value)
except:
print "%s probably not in tags list" %tag
print "check scOSCMessage.py - def decodeSCOSC():"
else:
print "Oops, typetag lacks the magic ,"
try:
returnList = [decoded[0]]
except IndexError:
returnList = []
try:
oldRtnList = returnList
returnList.extend(decoded[2:])
except IndexError:
returnList = oldRtnList
return returnList
示例14: main
# 需要导入模块: import OSC [as 别名]
# 或者: from OSC import decodeOSC [as 别名]
def main():
# Get controller and owner
controller = GameLogic.getCurrentController()
owner = controller.owner
# Set init
ip = '127.0.0.1' ### escucha router
port = 8886
'''if owner.name == "control_init":
port = 8887
else:
port = 8886'''
data = 0
# Connect Blender only one time
if not owner['connected']:
owner['connected'] = True
print ("Blender Connected user_presence ", owner.name)
print(port)
GameLogic.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
GameLogic.socket.bind((ip, port))
GameLogic.socket.setblocking(0)
GameLogic.socket.settimeout(0.02)
# If Blender connected, get osc
else:
# Get hand wii osc from pd
data = receive_osc(data, port)
#print(data)
if data != 0:
d = OSC.decodeOSC(data)
#print("decoded: ",d)
if d[0] == "/game/user-presence":
#print(d[2])
if d[2] == 2:
Game.user_presence = True
#print('player detected')
if d[2] == 1:
Game.user_presence = False
示例15: main
# 需要导入模块: import OSC [as 别名]
# 或者: from OSC import decodeOSC [as 别名]
def main():
# Get controller and owner
controller = GameLogic.getCurrentController()
owner = controller.owner
# Set init
ip = '127.0.0.1' ### escucha router
port = 8889
data = 0
# Connect Blender only one time
if not owner['connected']:
owner['connected'] = True
print ("Blender Connected game_start ", owner.name)
print(port)
GameLogic.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
GameLogic.socket.bind((ip, port))
GameLogic.socket.setblocking(0)
GameLogic.socket.settimeout(0.02)
# If Blender connected, get osc
else:
# Get hand wii osc from pd
data = receive_osc(data, port)
#print(data)
if data != 0:
d = OSC.decodeOSC(data)
#print("decoded: ",d)
if d[0] == "/game/start":
#print ("start",d[2])
if d[2] == 1:
Game.start = True
if d[2] == 0:
Game.start = False