本文整理汇总了Python中OSC.OSCClient类的典型用法代码示例。如果您正苦于以下问题:Python OSCClient类的具体用法?Python OSCClient怎么用?Python OSCClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OSCClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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)
示例3: messageServer
def messageServer(self, messagePath, argument):
client = OSCClient()
client.connect((self.serverIP, self.serverPort))
message = OSCMessage(messagePath)
message.append(argument)
client.send(message)
示例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)
示例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 ) )
示例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()
示例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()
示例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
示例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
示例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
示例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
示例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
示例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
示例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)
示例15: __init__
def __init__(self):
self.osc_message = None
self.osc_client = OSCClient()
self.osc_message = OSCMessage()
self.ip = ""
self.port = 0