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


Python OSCClient.send方法代码示例

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


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

示例1: SendOSC

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

示例2: messageServer

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

示例3: step_impl

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import send [as 别名]
def step_impl(context, host, port, int_one, int_sec):
    client = OSCClient()
    client.connect((host, port))
    if int_sec > 0:
        client.send(OSCMessage('/test', int_one, int_sec))
    else:
        client.send(OSCMessage('/test', int_one))
开发者ID:iaine,项目名称:sonification,代码行数:9,代码来源:writestream.py

示例4: __init__

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import send [as 别名]
class ColorsOut:

    def __init__(self):
        self.client = OSCClient()
        self.client.connect( ("localhost",11661) )

    def write(self, pixels):
        message = OSCMessage("/setcolors")
        pixels = self.crazyMofoingReorderingOfLights(pixels)
        message.append(pixels)
        self.client.send( message )
    
    def diff(self, pixels):
        message = OSCMessage("/diffcolors")
        message.append(pixels)
        self.client.send( message )

        

    def crazyMofoingReorderingOfLights(self, pixels):
        pixels2 = pixels[:] #make a copy so we don't kerplode someone's work
        """
        what are we expecting? we want the back left (by the couches) of the room to be pixel 0, 
        and by the front is the last row
        whereas in reality, it's the opposite.
        here is the order it'd be nice to have them in:
        
        0  1  2  3
        4  5  6  7
        8  9  10 11
        12 13 14 15
        16 17 18 19
        20 21 22 23

        this is the actual order:   
        23 22 21 20
        19 16 17 18
        15 14 13 12
        11 10 9  8
        3  2  5  4
        6 *0**1**7*   *=not there
        """

        actualorder = [23,22,21,20,19,16,17,18,15,14,13,12,11,10,9,8,3,2,5,4,6,0,1,7]
        badcolors = [3,2,5,4,6,0,1,7]
        for i in range(len(actualorder)):
            (r,g,b) = pixels[i]
            r = max(0.0, min(r, 1023.0))
            g = max(0.0, min(g, 1023.0))
            b = max(0.0, min(b, 1023.0))
            pixels2[actualorder[i]] = (r,g,b)
        for i in range(len(badcolors)):
            pixels2[badcolors[i]] = (0.0,0.0,0.0)



        return pixels2
开发者ID:tdkadich,项目名称:chroma-scripts,代码行数:59,代码来源:oscapi.py

示例5: Manta

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

示例6: oscSender

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

示例7: __init__

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import send [as 别名]
class ColorsOut:
    def __init__(self):
        self.client = OSCClient()
        self.client.connect( ("localhost",11661) )

    def write(self, pixels):
        message = OSCMessage("/setcolors")
        message.append(pixels)
        self.client.send( message )
    
    def diff(self, pixels):
        message = OSCMessage("/diffcolors")
        message.append(pixels)
        self.client.send( message )
开发者ID:SIGMusic,项目名称:twitter-music-pd,代码行数:16,代码来源:osc.py

示例8: StreamerOSC

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import send [as 别名]
class StreamerOSC(plugintypes.IPluginExtended):
	"""

	Relay OpenBCI values to OSC clients

	Args:
	  port: Port of the server
	  ip: IP address of the server
	  address: name of the stream
	"""
	    
	def __init__(self, ip='localhost', port=12345, address="/openbci"):
		# connection infos
		self.ip = ip
		self.port = port
		self.address = address
	
	# From IPlugin
	def activate(self):
		if len(self.args) > 0:
			self.ip = self.args[0]
		if len(self.args) > 1:
			self.port = int(self.args[1])
		if len(self.args) > 2:
			self.address = self.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) )

	# From IPlugin: close connections, send message to client
	def deactivate(self):
		self.client.send(OSCMessage("/quit") )
	    
	# send channels values
	def __call__(self, sample):
		mes = OSCMessage(self.address)
		mes.append(sample.channel_data)
		# silently pass if connection drops
		try:
			self.client.send(mes)
		except:
			return

	def show_help(self):
	  	print """Optional arguments: [ip [port [address]]]
开发者ID:Athuli7,项目名称:pybci,代码行数:48,代码来源:streamer_osc.py

示例9: Renoise

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import send [as 别名]
class Renoise(object):
    def __init__(self, address):
        self.client = OSCClient()
        self.client.connect(address)

    def panic(self):
        self.send_osc('/renoise/transport/panic')
    
    def note_on(self, instrument, track, note, velocity):
        self.send_osc('/renoise/trigger/note_on', instrument, track, note, velocity)
    
    def note_off(self, instrument, track, note):
        self.send_osc('/renoise/trigger/note_off', instrument, track, note)
    
    def send_osc(self, path, *args):
        msg = OSCMessage(path)
        map(msg.append, args)
        self.client.send(msg)
开发者ID:rknLA,项目名称:pymonome,代码行数:20,代码来源:renoise.py

示例10: on_data

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import send [as 别名]
    def on_data(self, data):
        #print(data)
        duration = 0
        try:
            all_data = json.loads(data)
            tweet = all_data["text"]
            split_tweet = tweet.split(' ')
            first_word = split_tweet[0]
            if first_word == 'RT':
                first_word = split_tweet[1]
            num = 0
            for char in first_word:
                num += ord(char)
            length_of_tweet = len(split_tweet)/40.0
            duration = length_of_tweet * 1000
            #print duration
            sharp_freqs = [185, 207.65, 233.08, 261.63, 277.18, 311.13, 349.23,]
            freqs = [174.61, 196, 220, 246.94, 261.63, 293.66, 329.62, 349.23, ]#369.99, 391.96, 415.30, 440, 466.16, 493.88, 523.25]
            note = num % 7
            freq = 0
            if '#' in tweet:
                freq = sharp_freqs[note]
            else:
                freq = freqs[note]
        except UnicodeEncodeError:
            duration = 500
        
        client = OSCClient()
        client.connect(("localhost", 54345))

        ### Create a bundle:
        bundle = OSCBundle()
        bundle.append({'addr': "/frequency", 'args':[freq]})
        #bundle.append({'addr': "/amplitude", 'args':[52]})
        #bundle.append({'addr': "/envelope/line", 'args:['})
        bundle.append({'addr': "/envelope/line", 'args': [10., 20, 0., duration]})

        client.send(bundle)


        time.sleep(duration/1000)
        
        return(True)
开发者ID:brandonkho,项目名称:TwitterSounds,代码行数:45,代码来源:send.py

示例11: OSCServer

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import send [as 别名]
class OSCServer(object):

	def __init__(self, ip, port,address="/openbci"):
		self.ip = ip
		self.port = port
		self.address = address
		
		# 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) )	

	def handle_sample(self, sample):
		mes = OSCMessage(self.address)
		mes.append(sample.channel_data)
		# silently pass if connection drops
		try:
			self.client.send(mes)
		except:
			return	
开发者ID:Razius123,项目名称:OpenBCI_Hub,代码行数:22,代码来源:oscserver.py

示例12: OSCForwarder

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import send [as 别名]
class OSCForwarder(threading.Thread):
   def __init__(self, from_ip, from_port, to_ip, to_port):
      super(OSCForwarder, self).__init__()

      # create the server to listen to messages arriving at from_ip
      self.server = OSCServer( (from_ip, from_port) )
      self.server.addMsgHandler( 'default', self.callback )

      # create the clieent to forward those message to to_ip
      self.client = OSCClient()
      self.client.connect( (to_ip, to_port) )

      print '%s:%d --> %s:%d' % (from_ip, from_port, to_ip, to_port)

      self.done_running = False

      # start the server listening for messages
      self.start()

   # close must be called before app termination or the app might hang
   def close(self):
      # this is a workaround of a bug in the OSC server
      # we have to stop the thread first, make sure it is done,
      # and only then call server.close()
      self.server.running = False

      while not self.done_running:
         time.sleep(.01)
      self.server.close()

   def run(self):
      #print "Worker thread entry point"
      self.server.serve_forever()
      self.done_running = True


   def callback(self, path, tags, args, source):
      #print 'got:', path, args, 'from:', source
      self.client.send( OSCMessage(path, args ) )
开发者ID:Vervious,项目名称:critters,代码行数:41,代码来源:oscbridge.py

示例13: OscProxyClient

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import send [as 别名]
class OscProxyClient(object):
    def __init__(self,
            remote_osc_address,
            json_to_osc_q,
            osc_command_name,
            bridge=None,
            *args, **kwargs):
        self.remote_osc_address = remote_osc_address
        self.json_to_osc_q = json_to_osc_q
        self.osc_client = OSCClient()
        self.osc_client.connect(remote_osc_address)
        self.osc_command_name = osc_command_name
        self.bridge = bridge
    
    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)
    
    def close(self):
        self.osc_client.close()
开发者ID:howthebodyworks,项目名称:parking_sun_lib,代码行数:26,代码来源:proxy_osc.py

示例14: sendOSC

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import send [as 别名]
    def sendOSC(self):
        """
        Send out some OSC using the values taken from the UI.
        """

        destHost = str(self.destEdit.displayText())
        destPort = int(self.portEdit.displayText())
        address = self.oscAddrEdit.displayText()
        type = self.dataCombo.currentText()
        payload = self.payLoadEdit.displayText()

        # TODO validate this data.

        oscClient = OSCClient()
        oscClient.connect((destHost,destPort))

        msg = OSCMessage(address)

        if type == "Integer":
            msg.append(int(payload), "i")
        elif type == "Float":
            msg.append(float(payload), "f")
        elif type == "String":
            msg.append(str(payload), "s")
        elif type == "OSC Blob":
            msg.append(0b001100, "b")

        try:
            oscClient.send(msg)
        except Exception:
            print Exception
        

        if debug:
            print "Sending OSC\nDestination: %s:%i, Address: %s, Type:%s" %\
                (destHost, destPort, address, type)
开发者ID:jamietirion,项目名称:osc-midi-bridge,代码行数:38,代码来源:osctester.py

示例15: OSCClient

# 需要导入模块: from OSC import OSCClient [as 别名]
# 或者: from OSC.OSCClient import send [as 别名]
#!/usr/local/bin/python

from OSC import OSCClient, OSCMessage
import time, math

period = 1
param_count = 9
param_low = 0
param_high = 127
frequency = 30

client = OSCClient()
client.connect( ("127.0.0.1", 50000) )

def oscillate(index):
  return int( (param_high + param_low) / 2.0 + ( ( param_high - param_low ) / 2.0 ) * math.sin(index + time.time() / period) )

while True:
  values = map(lambda i: oscillate(i), range(0, param_count))
  print values
  message = OSCMessage("/fish")
  message += values
  client.send( message )
  time.sleep(1.0 / frequency)
开发者ID:biotracking,项目名称:PCAMusiq,代码行数:26,代码来源:test_music_box.py


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