• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python OSC.OSCClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: init

def init(osc_setup):
    host, port, root = osc_setup
    client = OSCClient()
    client.connect( (host, port) )
    print "Connected to the OSC server %s:%s%s" %osc_setup
    send_parameter('osd_initialized','Done')
    return client
开发者ID:centime,项目名称:easyLeap,代码行数:7,代码来源:OscSend.py


示例2: 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


示例3: 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


示例4: 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


示例5: oscSender

class oscSender(object):

	def __init__(self,port):
		self.client = OSCClient()
		self.client.connect( ("172.16.1.110", port) )
		print "Started server on port : " + str(port)

	def newNode(self,args,BSSID,kind):
		msg = OSCMessage("/new" )
		msg.append(kind.strip())
		msg.append(args)
		msg.append(BSSID.strip()) 
		self.client.send(msg)
		# print "new"

	def updateNode(self,args,BSSID,kind):
		if BSSID == " ":
			return 
		msg =  OSCMessage("/update")
		msg.append(kind.strip())
		msg.append(args)
		msg.append(BSSID.strip()) 
		self.client.send(msg)
		# print "update"

	def removeNode(self,args,BSSID, kind):
		msg =  OSCMessage("/remove")
		msg.append(kind.strip())
		msg.append(args)
		msg.append(BSSID.strip())  
		self.client.send(msg)

	def closeConnection(self):
		self.client.send( OSCMessage("/quit", args ) )
开发者ID:bcadam,项目名称:airoViz,代码行数:34,代码来源:oscSender.py


示例6: main

def main():
    global bRun
    global inOSCport, outOSCport
    global myOSC_Server, myOSC_Client

    global cTrial, nTrials, breaksxTrial

    cTrial = 1 

    global debug_data
    global CS_US_1 

    CS_US_1['inputs']=[]

    cerebellumConfig['weights']=[]
    cerebellumConfig['config']=[]
    cerebellumConfig['constants']=[]


    debug_data['trials']=[]
    if save_bases:
        debug_data['basis']=[]
    debug_data['inputs']=[]

    inOSCport = 1234
    outOSCport = 1235
    
    # myOSC_Server = OSCServer( ('' , inOSCport) )
    # myOSC_Client = OSCClient()
    # myOSC_Client.connect( ('10.0.0.116' , outOSCport) )

    myOSC_Server = OSCServer( ('127.0.0.1' , inOSCport) )
    myOSC_Client = OSCClient()
    myOSC_Client.connect( ('127.0.0.1' , outOSCport) )
    
    print "Receiving messages /trial,/input in port", inOSCport
    print "Sending messages to port", outOSCport


    myOSC_Server.addMsgHandler("/config", receiveConfig)
    myOSC_Server.addMsgHandler("/trial", receiveTrial)
    myOSC_Server.addMsgHandler("/endtrial", receiveEndTrial)
    myOSC_Server.addMsgHandler("/input", receiveInput)
    myOSC_Server.addMsgHandler("/debug", receiveDebug)
    myOSC_Server.addMsgHandler("/update", receiveUpdate)
    myOSC_Server.addMsgHandler("/freeze", receiveFreeze)
    myOSC_Server.addMsgHandler("/saveConfig", receiveSaveConf)
    

    

    # if (cTrial==nTrials):
    #     pl.figure(figsize=(10,6))
    #     plot(breaksxTrial)

    
    print "Ready"

    myOSC_Server.serve_forever()
开发者ID:tcstewar,项目名称:telluride2014,代码行数:59,代码来源:cerebellarIROSExperimentRobotSaveConf.py


示例7: connectOsc

def connectOsc():
    global client, timeLastConnection
    if timeLastConnection < time.time() - 7200:
        print("connecting to OSC server")
        updateDNS()
        client = OSCClient()
        client.connect( ("146.164.80.56", 22244) )
        timeLastConnection = time.time()
开发者ID:hiperorganicos,项目名称:SHAST,代码行数:8,代码来源:old_motion.py


示例8: sendOSCnextlevel

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,代码行数:10,代码来源:Game.py


示例9: sendOSCend

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,代码行数:11,代码来源:ENDsoundengine.py


示例10: send_destroy

 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,代码行数:11,代码来源:Level.py


示例11: send_choque

 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,代码行数:11,代码来源:Level.py


示例12: send_stop

 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,代码行数:11,代码来源:Level.py


示例13: send_osccreation

 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,代码行数:11,代码来源:Level.py


示例14: Manta

class Manta(object):

    def __init__(self, receive_port=31416, send_port=31417, send_address='127.0.0.1'):
        self.osc_client = OSCClient()
        self.osc_server = OSCServer(('127.0.0.1', receive_port))
        self.osc_client.connect(('127.0.0.1', send_port))
        # set the osc server to time out after 1ms
        self.osc_server.timeout = 0.001
        self.event_queue = []
        self.osc_server.addMsgHandler('/manta/continuous/pad',
                self._pad_value_callback)
        self.osc_server.addMsgHandler('/manta/continuous/slider',
                self._slider_value_callback)
        self.osc_server.addMsgHandler('/manta/continuous/button',
                self._button_value_callback)
        self.osc_server.addMsgHandler('/manta/velocity/pad',
                self._pad_velocity_callback)
        self.osc_server.addMsgHandler('/manta/velocity/button',
                self._button_velocity_callback)

    def process(self):
        self.osc_server.handle_request()
        ret_list = self.event_queue
        self.event_queue = []
        return ret_list

    def _pad_value_callback(self, path, tags, args, source):
        self.event_queue.append(PadValueEvent(args[0], args[1]))

    def _slider_value_callback(self, path, tags, args, source):
        touched = False if args[1] == 0xffff else True
        scaled_value = args[1] / 4096.0
        self.event_queue.append(SliderValueEvent(args[0], touched, scaled_value))

    def _button_value_callback(self, path, tags, args, source):
        pass

    def _pad_velocity_callback(self, path, tags, args, source):
        self.event_queue.append(PadVelocityEvent(args[0], args[1]))

    def _button_velocity_callback(self, path, tags, args, source):
        self.event_queue.append(ButtonVelocityEvent(args[0], args[1]))

    def _send_osc(self, path, *args):
        msg = OSCMessage(path)
        msg.append(args)
        self.osc_client.send(msg)

    def set_led_enable(self, led_type, enabled):
        self._send_osc('/manta/ledcontrol', led_type, 1 if enabled else 0)

    def set_led_pad(self, led_state, pad_index):
        self._send_osc('/manta/led/pad', led_state, pad_index)
开发者ID:ssfrr,项目名称:buffering,代码行数:53,代码来源:manta.py


示例15: __init__

 def __init__(self):
     self.osc_message = None
     self.osc_client = OSCClient()
     self.osc_message = OSCMessage()        
     
     self.ip = ""
     self.port = 0
开发者ID:RocioLO,项目名称:SoundGuidance,代码行数:7,代码来源:SoundGuidance.py


示例16: OscSender

class OscSender():
    def __init__(self, osc_setup):
        self.host, self.port, self.root = osc_setup
        self.client = OSCClient()
        self.client.connect( (self.host, self.port) )
        print "Connected to the OSC server %s:%s%s" %osc_setup
        self.send_parameter('osd_initialized','Done')

    def send_parameters(self, hand_params):
        for path, value in hand_params.items():
            self.send_parameter(path, value)

    def send_parameter(self, rel_path, data):
        full_path = self.root+rel_path
        #self.client.send( OSCMessage( full_path, data ) )
        print "[osc]\t%s\t\t\t%s" %(full_path, data)
开发者ID:centime,项目名称:easyLeap,代码行数:16,代码来源:OscSend.py


示例17: OSCServer

class OSCServer(object):

  def __init__(self, ip, port,address="/openbci"):
    self.ip = ip
    self.port = port
    self.address = address
	if len(args) > 0:
		self.ip = args[0]
	if len(args) > 1:
		self.port = args[1]
	if len(args) > 2:
		self.address = args[2]
	# init network
	print "Selecting OSC streaming. IP: ", self.ip, ", port: ", self.port, ", address: ", self.address
	self.client = OSCClient()
	self.client.connect( (self.ip, self.port) )	
开发者ID:prescottprue,项目名称:OpenBCI_Hub,代码行数:16,代码来源:streamer_osc.py


示例18: app

def app():
    global dxlIO, server, client
    ports = pypot.dynamixel.get_available_ports()
    if not ports:
        raise IOError('No port available.')
    dxlIO = pypot.dynamixel.DxlIO(ports[0])
    availableIDs = dxlIO.scan()
    server = OSCServer(('0.0.0.0', 8000))
    for motorID in availableIDs:
        server.addMsgHandler('/motor/' + str(motorID), motorHandler) # Register OSC handlers for each found ID
    client = OSCClient()
    client.connect(('localhost', 8001))
    print 'Ready. Found ID(s) ' + str(availableIDs)
    while True:
        server.handle_request()
        sleep(0.01)
开发者ID:ianisl,项目名称:DOS,代码行数:16,代码来源:app.py


示例19: __init__

 def __init__(self, ip='localhost', port=12345, address="/openbci"):
     # connection infos
     self.ip = ip
     self.port = port
     self.address = address
     self.client = OSCClient()
     self.client.connect( (self.ip, self.port) )
     self.board = bci.OpenBCIBoard()
开发者ID:gabrielibagon,项目名称:OpenBCI_MaxMSP,代码行数:8,代码来源:stream_osc.py


示例20: main

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,代码行数:17,代码来源:raspberry.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python OSC.OSCMessage类代码示例发布时间:2022-05-24
下一篇:
Python OMBManagerLocale._函数代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap