当前位置: 首页>>代码示例>>Python>>正文


Python OSC.OSCMessage类代码示例

本文整理汇总了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)
开发者ID:RocioLO,项目名称:SoundGuidance,代码行数:31,代码来源:SoundGuidance.py

示例2: serialComms

def serialComms():
	while run:
		proximity = ser.readline()
		proxMsg = OSCMessage()
		proxMsg.setAddress(OSCAddress)
		proxMsg.append(proximity)
		columnClient.send(proxMsg)
开发者ID:brooklynresearch,项目名称:UrbanMatters,代码行数:7,代码来源:OSCSerialTest.py

示例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
开发者ID:redFrik,项目名称:TrainingTheBeagle,代码行数:7,代码来源:osc_sendRepeatedly.py

示例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("/")
开发者ID:jimenaRL,项目名称:espaces,代码行数:26,代码来源:server.py

示例5: send

 def send(self, sample):
     mes = OSCMessage(self.address)
     mes.append(sample.channel_data)
     try:
         self.client.send(mes)
     except:
         return
开发者ID:gabrielibagon,项目名称:OpenBCI_MaxMSP,代码行数:7,代码来源:stream_osc.py

示例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)
开发者ID:Opensemble,项目名称:lhcvmm,代码行数:25,代码来源:lhcvmm.py

示例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
开发者ID:Dewb,项目名称:leapyosc,代码行数:7,代码来源:client.py

示例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)
开发者ID:husk00,项目名称:audiogames,代码行数:31,代码来源:Level.py

示例9: toggleMuteGroup

def toggleMuteGroup(channel, state):
 stringChannel = str(channel)
 muteAddress = '/config/mute/' + stringChannel
 msg = OSCMessage(muteAddress)
 msg.append(state)
 client.send(msg)
 print msg
开发者ID:misterhay,项目名称:RasMute,代码行数:7,代码来源:RasMute.py

示例10: messageServer

    def messageServer(self, messagePath, argument):
        client = OSCClient()
        client.connect((self.serverIP, self.serverPort))
        message = OSCMessage(messagePath)
        message.append(argument)

        client.send(message)
开发者ID:kevinmkarol,项目名称:lotht_game,代码行数:7,代码来源:server_interface.py

示例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)
开发者ID:howthebodyworks,项目名称:parking_sun_lib,代码行数:7,代码来源:proxy_osc.py

示例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()
开发者ID:dropmeaword,项目名称:prtkl-narcissus,代码行数:28,代码来源:main.py

示例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)
开发者ID:UsAndRufus,项目名称:Subterranea-Mancunia,代码行数:30,代码来源:game.py

示例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")
开发者ID:ovicin,项目名称:pyobd-pi,代码行数:30,代码来源:obd_osc_sender.py

示例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)
开发者ID:tanzilli,项目名称:pyOSC,代码行数:7,代码来源:receiver.py


注:本文中的OSC.OSCMessage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。