本文整理汇总了Python中OSC.OSCMessage类的典型用法代码示例。如果您正苦于以下问题:Python OSCMessage类的具体用法?Python OSCMessage怎么用?Python OSCMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OSCMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SendOSC
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)
示例2: serialComms
def serialComms():
while run:
proximity = ser.readline()
proxMsg = OSCMessage()
proxMsg.setAddress(OSCAddress)
proxMsg.append(proximity)
columnClient.send(proxMsg)
示例3: sendMessage
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
示例4: espaces_callback
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("/")
示例5: send
def send(self, sample):
mes = OSCMessage(self.address)
mes.append(sample.channel_data)
try:
self.client.send(mes)
except:
return
示例6: send_event
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)
示例7: send
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
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: toggleMuteGroup
def toggleMuteGroup(channel, state):
stringChannel = str(channel)
muteAddress = '/config/mute/' + stringChannel
msg = OSCMessage(muteAddress)
msg.append(state)
client.send(msg)
print msg
示例10: messageServer
def messageServer(self, messagePath, argument):
client = OSCClient()
client.connect((self.serverIP, self.serverPort))
message = OSCMessage(messagePath)
message.append(argument)
client.send(message)
示例11: serve_forever
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)
示例12: loop
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()
示例13: hardware_callback
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)
示例14: record_data
def record_data(self):
if(self.port is None):
return None
print "Logging started"
while 1:
localtime = datetime.now()
current_time = str(localtime.hour)+":"+str(localtime.minute)+":"+str(localtime.second)+"."+str(localtime.microsecond)
log_string = current_time
results = {}
for index in self.sensorlist:
(name, value, unit) = self.port.sensor(index)
log_string = log_string + ","+str(value)
results[obd_sensors.SENSORS[index].shortname] = value;
#send sensor data via OSC
message = OSCMessage()
message.setAddress("/"+obd_sensors.SENSORS[index].shortname)
message.append(value)
self.client.send(message)
gear = self.calculate_gear(results["rpm"], results["speed"])
log_string = log_string #+ "," + str(gear)
#send gear via OSC
message = OSCMessage()
message.setAddress("/gear")
message.append(gear)
self.client.send(message)
self.log_file.write(log_string+"\n")
示例15: fader_callback
def fader_callback(path, tags, args, source):
print ("path", path)
print ("args", args)
print ("source", source)
msg=OSCMessage("/1/rotary1")
msg.append(args);
client.send(msg)