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


Python OSCMessage.setAddress方法代码示例

本文整理汇总了Python中OSC.OSCMessage.setAddress方法的典型用法代码示例。如果您正苦于以下问题:Python OSCMessage.setAddress方法的具体用法?Python OSCMessage.setAddress怎么用?Python OSCMessage.setAddress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OSC.OSCMessage的用法示例。


在下文中一共展示了OSCMessage.setAddress方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: loop

# 需要导入模块: from OSC import OSCMessage [as 别名]
# 或者: from OSC.OSCMessage import setAddress [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()
开发者ID:dropmeaword,项目名称:prtkl-narcissus,代码行数:30,代码来源:main.py

示例2: sendMessage

# 需要导入模块: from OSC import OSCMessage [as 别名]
# 或者: from OSC.OSCMessage import setAddress [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
开发者ID:redFrik,项目名称:TrainingTheBeagle,代码行数:9,代码来源:osc_sendRepeatedly.py

示例3: serialComms

# 需要导入模块: from OSC import OSCMessage [as 别名]
# 或者: from OSC.OSCMessage import setAddress [as 别名]
def serialComms():
	while run:
		proximity = ser.readline()
		proxMsg = OSCMessage()
		proxMsg.setAddress(OSCAddress)
		proxMsg.append(proximity)
		columnClient.send(proxMsg)
开发者ID:brooklynresearch,项目名称:UrbanMatters,代码行数:9,代码来源:OSCSerialTest.py

示例4: send_oscbundle

# 需要导入模块: from OSC import OSCMessage [as 别名]
# 或者: from OSC.OSCMessage import setAddress [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)
开发者ID:husk00,项目名称:audiogames,代码行数:33,代码来源:Level.py

示例5: SendOSC

# 需要导入模块: from OSC import OSCMessage [as 别名]
# 或者: from OSC.OSCMessage import setAddress [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)
开发者ID:RocioLO,项目名称:SoundGuidance,代码行数:33,代码来源:SoundGuidance.py

示例6: record_data

# 需要导入模块: from OSC import OSCMessage [as 别名]
# 或者: from OSC.OSCMessage import setAddress [as 别名]
    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,代码行数:32,代码来源:obd_osc_sender.py

示例7: sendOSCnextlevel

# 需要导入模块: from OSC import OSCMessage [as 别名]
# 或者: from OSC.OSCMessage import setAddress [as 别名]
def sendOSCnextlevel():
        client = OSCClient()
        msg = OSCMessage()
        # gl.client is a tuple in gl with ip and port
        address = "/game/nextlevel"
        msg.setAddress(address)
        msg.append(currentlevel)
        client.sendto(msg, gl.send_to)
        #print('Send message example =', msg, "to ", gl.send_to)
        return
开发者ID:husk00,项目名称:audiogames,代码行数:12,代码来源:Game.py

示例8: _oscHandler

# 需要导入模块: from OSC import OSCMessage [as 别名]
# 或者: from OSC.OSCMessage import setAddress [as 别名]
 def _oscHandler(self, addr, tags, stuff, source):
     addrTokens = addr.lstrip('/').split('/')
     ## list of all receivers
     if ((addrTokens[0].lower() == "localnet")
           and (addrTokens[1].lower() == "receivers")):
         ## as good, if not better than a ping
         self.lastPingTime = time.time()
         print "got receivers %s"%(stuff[0])        
         for rcvr in stuff[0].split(','):
             self.allReceivers[rcvr] = rcvr
         if(self.subscribedToAll and not self.subscribedReceivers):
             self.subscribeToAll()
     ## hijack /LocalNet/Add !
     elif ((addrTokens[0].lower() == "localnet")
         and (addrTokens[1].lower() == "add")):
         ip = getUrlStr(source).split(":")[0]
         port = int(stuff[0])
         print "adding %s:%s to PantallaServer" % (ip, port)
         self.allClients[(ip,port)] = addrTokens[2]
     ## hijack a /LocalNet/ListReceivers
     elif ((addrTokens[0].lower() == "localnet")
           and (addrTokens[1].lower().startswith("listreceiver"))):
         ip = getUrlStr(source).split(":")[0]
         port = int(stuff[0])
         ## send list of receivers to client
         msg = OSCMessage()
         msg.setAddress("/LocalNet/Receivers")
         msg.append(self.name)
         print "got a request for receivers from %s:%s"%(ip,port)
         try:
             #self.oscClient.connect((ip, port))
             self.oscClient.sendto(msg, (ip, port))
             #self.oscClient.connect((ip, port))
         except OSCClientError:
             print "no connection to %s:%s, can't send list of receivers"%(ip,port)
     ## actual message from AEffect Network !!
     elif (addrTokens[0].lower() == "aeffectlab"):
         self.messageQ.put((addrTokens[1],
                            addrTokens[2],
                            stuff[0].decode('utf-8')))
         self.messageQ.put((addrTokens[1],
                            addrTokens[2],
                            stuff[0].decode('utf-8')))
     ## ping
     if ((addrTokens[0].lower() == "localnet")
         and (addrTokens[1].lower() == "ping")):
         self.lastPingTime = time.time()
         # forward to clients
         for (ip,port) in self.allClients.keys():
             try:
                 #self.oscClient.connect((ip, int(port)))
                 self.oscClient.sendto(self.oscPingMessage, (ip, int(port)))
                 #self.oscClient.connect((ip, int(port)))
             except OSCClientError:
                 print ("no connection to %s:%s, can't send bang"%(ip,port))
开发者ID:astrovandalistas,项目名称:Pantallas,代码行数:57,代码来源:pantallaserver.py

示例9: sendOSCend

# 需要导入模块: from OSC import OSCMessage [as 别名]
# 或者: from OSC.OSCMessage import setAddress [as 别名]
def sendOSCend():
        #
        client = OSCClient()
        msg = OSCMessage()
        # gl.client is a tuple in gl with ip and port
        address = "/game/end"
        msg.setAddress(address)
        msg.append(1)
        client.sendto(msg, gl.send_to)
        print('Send message example =', msg, "to ", gl.send_to)
        return
开发者ID:husk00,项目名称:audiogames,代码行数:13,代码来源:ENDsoundengine.py

示例10: send_stop

# 需要导入模块: from OSC import OSCMessage [as 别名]
# 或者: from OSC.OSCMessage import setAddress [as 别名]
 def send_stop(self):
     # da stop al soundengine
     client = OSCClient()
     msg = OSCMessage()
     # gl.client is a tuple in gl with ip and port
     address = "/game/stop"
     msg.setAddress(address)
     msg.append(0)
     client.sendto(msg, gl.send_to)
     #print('Send message example =', msg, "to ", gl.send_to)
     return
开发者ID:husk00,项目名称:audiogames,代码行数:13,代码来源:Level.py

示例11: serialComms

# 需要导入模块: from OSC import OSCMessage [as 别名]
# 或者: from OSC.OSCMessage import setAddress [as 别名]
def serialComms():
	while run:
		proximity = ser.readline()
		proxMsg = OSCMessage()
		proxMsg.setAddress(OSCAddress)
		proxMsg.append(proximity)
		try:
			columnClient.send(proxMsg)
		except:
			print("client unavailable")
			pass
开发者ID:brooklynresearch,项目名称:UrbanMatters,代码行数:13,代码来源:UrbanMatters_SoundChamber.py

示例12: send_osccreation

# 需要导入模块: from OSC import OSCMessage [as 别名]
# 或者: from OSC.OSCMessage import setAddress [as 别名]
 def send_osccreation(self, lista):
     # crea los objetos en el sound engine
     client = OSCClient()
     msg = OSCMessage()
     # gl.client is a tuple in gl with ip and port
     address = "/game/create"
     msg.setAddress(address)
     msg.append(lista)
     client.sendto(msg, gl.send_to)
     #print('Send message example =', msg, "to ", gl.send_to)
     return
开发者ID:husk00,项目名称:audiogames,代码行数:13,代码来源:Level.py

示例13: sendMessage

# 需要导入模块: from OSC import OSCMessage [as 别名]
# 或者: from OSC.OSCMessage import setAddress [as 别名]
def sendMessage():
    msg = OSCMessage()
    msg.setAddress("/oscTest")
    msg.append(100)
    print "Sending '/oscTest 100' message to SuperCollider"
    try:
        client.send(msg)
    except:
        print "Waiting for SuperCollider to become available..."
        pass
    timedSendMessage()  # recursive call, keeps the timer going
开发者ID:redFrik,项目名称:TrainingTheBeagle,代码行数:13,代码来源:osc_sendRepeatedly-WithErrorHandling.py

示例14: send_choque

# 需要导入模块: from OSC import OSCMessage [as 别名]
# 或者: from OSC.OSCMessage import setAddress [as 别名]
 def send_choque(self):
     #
     client = OSCClient()
     msg = OSCMessage()
     # gl.client is a tuple in gl with ip and port
     address = "/player/choque"
     msg.setAddress(address)
     msg.append(0)
     client.sendto(msg, gl.send_to)
     #print('Send message example =', msg, "to ", gl.send_to)
     return
开发者ID:husk00,项目名称:audiogames,代码行数:13,代码来源:Level.py

示例15: send_destroy

# 需要导入模块: from OSC import OSCMessage [as 别名]
# 或者: from OSC.OSCMessage import setAddress [as 别名]
 def send_destroy(self,id):
     #
     client = OSCClient()
     msg = OSCMessage()
     # gl.client is a tuple in gl with ip and port
     address = "/game/sndobj/destroy"
     msg.setAddress(address)
     msg.append(id)
     client.sendto(msg, gl.send_to)
     #print('Send message example =', msg, "to ", gl.send_to)
     return    
开发者ID:husk00,项目名称:audiogames,代码行数:13,代码来源:Level.py


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