本文整理汇总了Python中OSC.OSCMessage.append方法的典型用法代码示例。如果您正苦于以下问题:Python OSCMessage.append方法的具体用法?Python OSCMessage.append怎么用?Python OSCMessage.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OSC.OSCMessage
的用法示例。
在下文中一共展示了OSCMessage.append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: espaces_callback
# 需要导入模块: from OSC import OSCMessage [as 别名]
# 或者: from OSC.OSCMessage import append [as 别名]
def espaces_callback(path, tags, args, source):
msg_string = ""
msg_string += "\n\tpath : %s" % path
msg_string += "\n\ttags : %s" % tags
msg_string += "\n\targs : %s" % args
msg_string += "\n\tsource :%s" % str(source)
print "OSCServer received: %s\nfrom %s.\n" % (msg_string, getUrlStr(source))
ir_params = { 'duration' : float(args[4]),
'nu' : float(args[5]),
'sampling_rate' : float(args[6]),
'ev_params' : {'space': str(args[1]), 'c':float(args[2]), 'j_max':int(args[3]),'F':list(args[7:])},
}
command = espace_client.handle_request(ir_params)
# send reply to the client
reply_port = int(args[0])
reply_addresse = (source[0], reply_port)
msg = OSCMessage("/pd")
msg.append(command['saved_audio_path'])
server.client.sendto(msg,reply_addresse,timeout=1)
print "OSCServer send:\n\t%s\nto %s.\n" %(msg,reply_addresse)
return OSCMessage("/")
示例2: SendOSC
# 需要导入模块: from OSC import OSCMessage [as 别名]
# 或者: from OSC.OSCMessage import append [as 别名]
class SendOSC(object):
def __init__(self):
self.osc_message = None
self.osc_client = OSCClient()
self.osc_message = OSCMessage()
self.ip = ""
self.port = 0
def connect(self, ip="localhost", port=8080):
self.ip = ip
self.port = port
self.osc_client.connect((self.ip, self.port))
def send(self, address, value):
self.osc_message.setAddress(address)
self.osc_message.append(value)
self.osc_client.send(self.osc_message)
def send_distane(self, distance):
oscdump = "/dumpOSC/DistanceTipTarget"
self.send(oscdump, distance)
def send_needle_tip_position(self, x, y, z):
oscdump = "/dumpOSC/needltip/x"
self.send(oscdump, x)
oscdump = "/dumpOSC/needltip/y"
self.send(oscdump, y)
oscdump = "/dumpOSC/needltip/z"
self.send(oscdump, z)
示例3: send_event
# 需要导入模块: from OSC import OSCMessage [as 别名]
# 或者: from OSC.OSCMessage import append [as 别名]
def send_event():
spectral_densities = ['filled', 'packed', 'opaque','translucent','transparent','empty']
# fill blanks
data = ['']*17*3
#onset, continuant, termination
data[0] = 'attack'
#elegimos el de mayor momento transversal
i = [l for l in tree.lep_pt].index(max(tree.lep_pt))
#duration, based on momento transversal .. lep_pt
data[1] = mapValue(tree.lep_pt[i],0,100000,0.1,10)
#Spectrum types: electrones : inarmonico , muones: granular
data[10] = 'inharmonic' if tree.lep_type[i] == 11 else 'granular'
#Spectrum occupation: angulo
data[11] = 'center'
#Spectrum density: lepton energy .. lep_E
data[16] = spectral_densities[int(mapValue(tree.lep_E[i],0,100000,0,5))]
bundle = OSCBundle()
msg = OSCMessage("/"+args.messagename)
for d in data:
msg.append(d)
bundle.append(msg)
client.send(bundle)
示例4: sendMessage
# 需要导入模块: from OSC import OSCMessage [as 别名]
# 或者: from OSC.OSCMessage import append [as 别名]
def sendMessage():
msg = OSCMessage()
msg.setAddress("/oscTest")
msg.append(100)
print "sending '/oscTest 100' message to SuperCollider"
client.send(msg)
timedSendMessage() # recursive call, keeps the timer going
示例5: serialComms
# 需要导入模块: from OSC import OSCMessage [as 别名]
# 或者: from OSC.OSCMessage import append [as 别名]
def serialComms():
while run:
proximity = ser.readline()
proxMsg = OSCMessage()
proxMsg.setAddress(OSCAddress)
proxMsg.append(proximity)
columnClient.send(proxMsg)
示例6: send
# 需要导入模块: from OSC import OSCMessage [as 别名]
# 或者: from OSC.OSCMessage import append [as 别名]
def send(self, sample):
mes = OSCMessage(self.address)
mes.append(sample.channel_data)
try:
self.client.send(mes)
except:
return
示例7: send
# 需要导入模块: from OSC import OSCMessage [as 别名]
# 或者: from OSC.OSCMessage import append [as 别名]
def send(self,name,val=None):
msg = OSCMessage(name)
if val is not None:
msg.append(val)
r = self.client.send(msg)
self.osc_messages_sent += 1
return r
示例8: send_oscbundle
# 需要导入模块: from OSC import OSCMessage [as 别名]
# 或者: from OSC.OSCMessage import append [as 别名]
def send_oscbundle(self):
# send a bundle with current bpm and polar coordinates of
# sound-objects relative to player
# /game/bpm
client = OSCClient()
bpm = OSCMessage()
bpm.setAddress("/game/bpm")
bpm.append(self.player['bpm'])
bundle = OSCBundle()
bundle.append(bpm)
# /game/sndobj/id-bola (ang, mod)
scn = bge.logic.getCurrentScene()
play = scn.objects["player"]
for ball in self.soundobjects:
ballpos = ball.worldPosition
vect = mathutils.Vector((0,1))
dist = play.getVectTo(ballpos)[0]
vect2 = play.getVectTo(ballpos)[2].to_2d()
angle = math.degrees(-vect.angle_signed(vect2))
#print("angle ", angle, "distancia ",dist)
data = (angle, dist)
# append data to bundle
msg = OSCMessage()
tag = "/game/sndobj/position/" + str(ball['id'])
msg.setAddress(tag)
msg.append(data)
bundle.append(msg)
#print(msg)
#gl.client is a tuple in gl with ip and port
client.sendto(bundle, gl.send_to)
示例9: __init__
# 需要导入模块: from OSC import OSCMessage [as 别名]
# 或者: from OSC.OSCMessage import append [as 别名]
def __init__(self, address):
OSCServer.__init__(self, ('', 0))
self.client.connect(address)
host, port = self.client.socket.getsockname()
# print "I believe we have an OSC Server listening on: ",host," ",port
print port
self.focused = False
#self.server_host = host
#self.server_port = port
self.prefix = DEFAULT_PREFIX
self.addMsgHandler('default', self.monome_handler)
self.addMsgHandler('/sys/connect', self.sys_misc)
self.addMsgHandler('/sys/disconnect', self.sys_misc)
self.addMsgHandler('/sys/id', self.sys_misc)
self.addMsgHandler('/sys/size', self.sys_size)
self.addMsgHandler('/sys/host', self.sys_host)
self.addMsgHandler('/sys/port', self.sys_port)
self.addMsgHandler('/sys/prefix', self.sys_prefix)
self.addMsgHandler('/sys/rotation', self.sys_misc)
# handshake
msg = OSCMessage("/sys/host")
msg.append(host)
self.client.send(msg)
msg = OSCMessage("/sys/port")
msg.append(port)
self.client.send(msg)
msg = OSCMessage("/sys/info")
self.client.send(msg)
示例10: messageServer
# 需要导入模块: from OSC import OSCMessage [as 别名]
# 或者: from OSC.OSCMessage import append [as 别名]
def messageServer(self, messagePath, argument):
client = OSCClient()
client.connect((self.serverIP, self.serverPort))
message = OSCMessage(messagePath)
message.append(argument)
client.send(message)
示例11: toggleMuteGroup
# 需要导入模块: from OSC import OSCMessage [as 别名]
# 或者: from OSC.OSCMessage import append [as 别名]
def toggleMuteGroup(channel, state):
stringChannel = str(channel)
muteAddress = '/config/mute/' + stringChannel
msg = OSCMessage(muteAddress)
msg.append(state)
client.send(msg)
print msg
示例12: serve_forever
# 需要导入模块: from OSC import OSCMessage [as 别名]
# 或者: from OSC.OSCMessage import append [as 别名]
def serve_forever(self):
for msg in self.json_to_osc_q:
osc_msg = OSCMessage(self.osc_command_name)
osc_msg.append(msg[0]) #HTTP verb
osc_msg.append(msg[1]) #HTTP path
osc_msg.append(msg[2]) #content
self.osc_client.send(osc_msg)
示例13: loop
# 需要导入模块: from OSC import OSCMessage [as 别名]
# 或者: from OSC.OSCMessage import append [as 别名]
def loop(serial, host, port):
osctx = osc_init( (host, port) )
bitadev = bitalino_init(serial)
if not bitadev:
raise Exception("Coultdn't open the BITalino device")
try:
print "Entering reading loop..."
while True:
samples = bitadev.read()
time.sleep(0.005)
#bitadev.trigger(digitalOutput)
for s in samples:
msg = OSCMessage()
msg.setAddress("/biosample")
out = []
for sval in s:
out.append(sval / 1024)
msg.append(out)
#print msg
osctx.send( msg )
except KeyboardInterrupt as e:
print "Looks like you wanna leave. Good bye!"
finally:
bitadev.stop()
bitadev.close()
示例14: hardware_callback
# 需要导入模块: from OSC import OSCMessage [as 别名]
# 或者: from OSC.OSCMessage import append [as 别名]
def hardware_callback(addr, tags, d, client_address):
#d is data
h_id = int(addr.split("/")[-1])
event = None
error = False
if h_id == JUNCTION:
if len(d) == 13:
#create event object
event = pygame.event.Event(NETWORK_HARDWARE,{"hardware_id":JUNCTION,
"topRowOn":d[0],1:d[1],2:d[2],3:d[3],4:d[4],5:d[5],6:d[6],
7:d[7],8:d[8],9:d[9],10:d[10],11:d[11],12:d[12]})
else:
error = True
elif h_id == SCIENCE:
event = pygame.event.Event(NETWORK_HARDWARE,{"hardware_id":SCIENCE,"s1":True})
elif h_id == COMMANDER:
event = pygame.event.Event(NETWORK_HARDWARE,{"hardware_id":COMMANDER,"has_power":True})
elif h_id == RADIO:
event = pygame.event.Event(NETWORK_HARDWARE,{"hardware_id":RADIO,"frequency":55})
if event != None:
pygame.event.post(event)
if error:
#object malformed, return error
msg = OSCMessage("/user/1")
msg.append("Error")
server.client.sendto(msg,client_address)
示例15: nunchuk
# 需要导入模块: from OSC import OSCMessage [as 别名]
# 或者: from OSC.OSCMessage import append [as 别名]
def nunchuk(self, state):
"""
Extract acceleration, pitch, roll and both buttons
from the nunchuk.
"""
# Need to calculate pitch and roll here...
a_x = state['acc'][0] - self.cal_n_x
a_y = state['acc'][1] - self.cal_n_y
a_z = state['acc'][2] - self.cal_n_z
roll = atan(a_x/a_z)
pitch = atan(a_y/a_z*cos(roll))
msg = OSCMessage('/nunchuk/acc')
msg.append((a_x, a_y, a_z))
self.client.sendto(msg=msg, address=self.address)
msg = OSCMessage('/nunchuk/orientation')
msg.append((pitch, roll))
self.client.sendto(msg=msg, address=self.address)
msg = OSCMessage('/nunchuk/joystick')
msg.append(state['stick'])
self.client.sendto(msg=msg, address=self.address)
msg_z = OSCMessage('/nunchuk/button/z')
msg_c = OSCMessage('/nunchuk/button/c')
z = 0
c = 0
if state['buttons'] in [1, 3]:
z = 1
if state['buttons'] in [2,3]:
c = 1
msg_z.append(z)
msg_c.append(c)
self.client.sendto(msg=msg_z, address=self.address)
self.client.sendto(msg=msg_c, address=self.address)