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


Python OSCClient.sendto方法代码示例

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


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

示例1: send_oscbundle

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import sendto [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

示例2: sendOSCnextlevel

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import sendto [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

示例3: send_choque

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import sendto [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

示例4: send_destroy

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import sendto [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

示例5: send_stop

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import sendto [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

示例6: send_osccreation

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import sendto [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

示例7: sendOSCend

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import sendto [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

示例8: main

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import sendto [as 别名]
def main():
    led_setup()
    client = OSCClient()
    address = ('127.0.0.1', 6666)
    while True:
        state = hand_state()
        led_control(state)
        if state['left']:
            msg = OSCMessage('/volume')
            msg.append(clamp(state['left'], 100, 600))
            client.sendto(msg, address)
        if state['right']:
            msg = OSCMessage('/pitch')
            msg.append(clamp(state['right'], 100, 600))
            client.sendto(msg, address)
        time.sleep(0.01)
    led_teardown()
开发者ID:wasamasa,项目名称:theremin,代码行数:19,代码来源:raspberry.py

示例9: send_osclocation

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import sendto [as 别名]
 def send_osclocation(self):
     #cuando hay un cambio de situacion se envia
     #           /player/in    /player/out      /player/border
     client = OSCClient()
     msg = OSCMessage()
     # gl.client is a tuple in gl with ip and port
     if self['location'] == 'IN':
         address = "/player/in"
     elif self['location'] == 'OUT':
         address = "/player/out"
     else:
         address = "/player/border"
     msg.setAddress(address)
     msg.append(1)
     client.sendto(msg, gl.send_to)
     print(msg)
     #print('Send message example =', msg, "to ", gl.send_to)
     return 
开发者ID:husk00,项目名称:audiogames,代码行数:20,代码来源:Player.py

示例10: quick_message

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import sendto [as 别名]
def quick_message(host, port, path, *args):
    msg = OSCMessage(path)
    [msg.append(d) for d in args]
    client = OSCClient()
	client.sendto(msg, (host, port), timeout=0)
开发者ID:Old-Stuff,项目名称:griddle,代码行数:7,代码来源:meme.py

示例11: PantallaServer

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import sendto [as 别名]
class PantallaServer(PrototypeInterface):
    """ Pantalla prototype class
        all prototypes must define setup() and loop() functions
        self.messageQ will have all messages coming in from LocalNet """

    ## overide the osc handler
    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))

    def setup(self):
        self.name = "VLE"
        self.allClients = {}
        self.oscClient = OSCClient()
        ## subscribe to all receivers from localnet
        self.subscribeToAll()
        self.oldMessages = []
        self.lastQueueCheck = time.time()
        self.oscPingMessage = OSCMessage()
        self.oscPingMessage.setAddress("/LocalNet/Ping")
        ## use empty byte blob
        self.oscPingMessage.append("", 'b')


    def _oneWordToEach(self, locale,type,txt):
        clientIndex = 0
        words = txt.split()
        for w in words:
            msg = OSCMessage()
            msg.setAddress("/AeffectLab/"+locale+"/"+type)
            msg.append(w.encode('utf-8'), 'b')
            (ip,port) = self.allClients.keys()[clientIndex]

            try:
                #self.oscClient.connect((ip, int(port)))
                self.oscClient.sendto(msg, (ip, int(port)))
                #self.oscClient.connect((ip, int(port)))
            except OSCClientError:
                print "no connection to %s:%s, can't send message "%(ip,port)
                #del self.allClients[(ip,port)]
            
            if (self.allClients):
                clientIndex = (clientIndex+1)%len(self.allClients.keys())

    def _oneMessageToEach(self, locale,type,txt):
        clientKeys = self.allClients.keys()
        ## get a random client to push the new message
        shuffle(clientKeys,random)
#.........这里部分代码省略.........
开发者ID:astrovandalistas,项目名称:Pantallas,代码行数:103,代码来源:pantallaserver.py

示例12: waffle_send

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import sendto [as 别名]
 def waffle_send(self, path, *args):
     msg = OSCMessage(path)
     map(msg.append, args)
     client = OSCClient()
     client.sendto(msg, (self.app_host, self.app_port), timeout=0)
开发者ID:artfwo,项目名称:griddle,代码行数:7,代码来源:griddle.py

示例13: waffle_send_any

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import sendto [as 别名]
 def waffle_send_any(self, host, port, path, *args):
     msg = OSCMessage(path)
     map(msg.append, args)
     client = OSCClient()
     client.sendto(msg, (host, port), timeout=0)
开发者ID:artfwo,项目名称:griddle,代码行数:7,代码来源:griddle.py

示例14: Wiimy_mapping

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import sendto [as 别名]
class Wiimy_mapping(object):
    """
        Class designed to send the wiimote state via OSC.
        Sends acc, nunchuk and buttons state messages from cwiid.
        The update state 
    """


    def __init__(self, address=('localhost', 5600)):
        """ Set up a connection to the address specified. """ 
        self.client = OSCClient()
        self.address = address
        self.prev_state = None


    def set_acc_cal(self, remote_cal, nunchuk_cal):
        """
            Receives the initial calibration values for
            the remote and the nunchuk. These are used to 
            calculate pitch and roll :)

        """
        self.cal_r_x = remote_cal[0][0] /(remote_cal[1][0] - remote_cal[0][0])
        self.cal_r_y = remote_cal[0][1] /(remote_cal[1][1] - remote_cal[0][1])
        self.cal_r_z = remote_cal[0][2] /(remote_cal[1][2] - remote_cal[0][2])
        self.cal_n_x = nunchuk_cal[0][0] /(nunchuk_cal[1][0] - nunchuk_cal[0][0])
        self.cal_n_y = nunchuk_cal[0][1] /(nunchuk_cal[1][1] - nunchuk_cal[0][1])
        self.cal_n_z = nunchuk_cal[0][2] /(nunchuk_cal[1][2] - nunchuk_cal[0][2])

    def update_state(self, state):
        """
            
        """
        state = parse_state(state)
        if self.prev_state:
           for k in state:
               if not self.prev_state[k] == state[k]:
                   getattr(self, k)(state[k])
           self.prev_state = state     
        else:
            self.prev_state = state
            for k in state.keys():
                getattr(self, k)(state[k])
        
        
    def acc(self, state):
        """ 
            Extract acceleration, pitch and roll from the wiimote.

        """
        # Need to calculate pitch and roll here...
        a_x = state[0] - self.cal_r_x
        a_y = state[1] - self.cal_r_y
        a_z = state[2] - self.cal_r_z
        roll = atan(a_x/a_z)
        if a_z < 0.0:
            if a_x > 0.0:
                roll += pi
            else:
                roll += (pi * -1)
        roll *= -1
        pitch = atan(a_y/a_z*cos(roll))
        msg = OSCMessage('/wii/acc')
        msg.append((a_x, a_y, a_z))
        self.client.sendto(msg=msg, address=self.address)
        msg = OSCMessage('/wii/orientation')
        msg.append((pitch, roll))
        self.client.sendto(msg=msg, address=self.address)

    def buttons(self, state):
        """ Extract button A, minus and plus only. """

        msg_a = OSCMessage('/wii/button/a')
        msg_minus = OSCMessage('/wii/button/minus')
        msg_plus = OSCMessage('/wii/button/plus')
        a = 0
        minus = 0
        plus = 0
        if state in (8, 24, 4104, 4120):
            a = 1
        if state in (16, 24, 4104, 4120):
            minus = 1
        if state in (4096, 24, 4104, 4120):
            plus = 1
        msg_a.append(a)
        msg_minus.append(minus)
        msg_plus.append(plus)
        self.client.sendto(msg=msg_a, address=self.address)
        self.client.sendto(msg=msg_minus, address=self.address)
        self.client.sendto(msg=msg_plus, address=self.address)

    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
#.........这里部分代码省略.........
开发者ID:nkundiushuti,项目名称:Wiiphone,代码行数:103,代码来源:wiimoteHandler.py

示例15: Wiimy_mapping

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import sendto [as 别名]
class Wiimy_mapping(object):
    """
        Class designed to send the wiimote state via OSC.
        Sends acc, nunchuk and buttons state messages from cwiid.
        This is a base class template, it ought to be extended
        to implement specific mapping strategies.
        acc, buttons and nunchuk can be overriden.
        
    """


    def __init__(self, address=('localhost', 5600)):
        """ Set up a connection to the address specified. """ 
        self.client = OSCClient()
        self.address = address
        self.prev_state = None


    def set_acc_cal(self, remote_cal, nunchuk_cal=None):
        """
            Receives the initial calibration values for
            the remote and the nunchuk. These are used to 
            calculate pitch and roll :)

        """
        self.cal_r_x = \
            remote_cal[0][0] /(remote_cal[1][0] - remote_cal[0][0])
        self.cal_r_y = \
            remote_cal[0][1] /(remote_cal[1][1] - remote_cal[0][1])
        self.cal_r_z = \
            remote_cal[0][2] /(remote_cal[1][2] - remote_cal[0][2])
        if nunchuk_cal:
            self.cal_n_x = \
                nunchuk_cal[0][0] /(nunchuk_cal[1][0] - nunchuk_cal[0][0])
            self.cal_n_y = \
                nunchuk_cal[0][1] /(nunchuk_cal[1][1] - nunchuk_cal[0][1])
            self.cal_n_z = \
                nunchuk_cal[0][2] /(nunchuk_cal[1][2] - nunchuk_cal[0][2])

    def update_state(self, state):
        """
            
        """
        if hasattr(self, 'cal_n_x'):
            state = full_mapping(state)
        else:
            state = mapping_no_nunchuk(state)
        if self.prev_state:
           for k in state:
               if not self.prev_state[k] == state[k]:
                   getattr(self, k)(state[k])
           self.prev_state = state     
        else:
            self.prev_state = state
            for k in state.keys():
                getattr(self, k)(state[k])
        
        
    def acc(self, state):
        """ 
            Extract acceleration, pitch and roll from the wiimote.
            Stub method which can be extended in a subclass to 
            implement specific mappping strategies and send custom messages.

        """
        # Normalise values and calculate pitch and roll
        a_x = state[0] - self.cal_r_x
        a_y = state[2] - self.cal_r_y
        a_z = state[1] - self.cal_r_z
        roll = atan(a_x/a_z)
        if a_z < 0.0:
            if a_x > 0.0:
                roll += pi
            else:
                roll += (pi * -1)
        roll *= -1
        pitch = atan(a_y/a_z*cos(roll))

        # Send OSC message to the server
        msg = OSCMessage('/acc')
        msg.append((a_x, a_z, a_y, pitch, roll))
        self.client.sendto(msg=msg, address=self.address)

    def buttons(self, state):
        """ 
            Stub method which can be extended in a subclass to 
            implement specific mappping strategies and send custom messages.
            The state parameter is a number. When no buttons are pressed 
            state is 0. Each button has it's own number but when multiple
            buttons are pressed these numbers are added together in the state
            variable.

            TODO: List all the button numbers here for convenience.

        """
        pass

    def nunchuk(self, state):
        """ 
            Receive all nunchuk info here: this method should be 
#.........这里部分代码省略.........
开发者ID:jgoconnell,项目名称:Wiiphone,代码行数:103,代码来源:wiimoteHandler.py


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