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


Python OSC类代码示例

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


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

示例1: parse_function

    def parse_function(self, data):
        # OSCulator uses big endian, OSC.py uses big endian
        name, rest = OSC.readString(data)
        
        if not name.startswith("/wii"):
            return
        
        type, rest = OSC.readString(rest)
        
        if name.endswith("/pry/0"):
            self.parse_field(rest, 'pitch', 'y')

        if name.endswith("pry/1"):
            self.parse_field(rest, 'roll', 'x')
        
        if name.endswith("pry/2"):
            self.parse_field(rest, 'yaw', 'z')
        
        if name.endswith("button/A"):
            self.a = self.readFloat(rest)[0]
            
        if name.endswith("button/B"):
            b = self.readFloat(rest)[0]
            
            if self.b and not b:
                self.tool_server.on_mouse_release(0, 0, 0, 0)
            elif not self.b and b:
                self.tool_server.on_mouse_press(0, 0, 0, 0)               
            
            self.b = b
开发者ID:cmorgan,项目名称:dypy,代码行数:30,代码来源:WiimoteDevice.py

示例2: main

 def main(self):
     """ Main loop """
     while 1:
         if self.dataReady("control"):
             msg = self.recv("control")
             if (isinstance(msg, producerFinished) or
                 isinstance(cmsg, shutdownMicroprocess)):
                 self.send(msg, "signal")
                 break
         if self.dataReady("inbox"):
             data = self.recv("inbox")
             if self.index is None:
                 decoded = OSC.decodeOSC(data)
                 # Send decoded data as (address, [arguments], timetag) tuple
                 self.send((decoded[2][0], decoded[2][2:], decoded[1]),
                           "outbox")
             else:
                 decoded = OSC.decodeOSC(data[self.index])
                 data = list(data)
                 data[self.index] = (decoded[2][0], decoded[2][2:],
                                        decoded[1])
                 self.send(data, "outbox") 
                 
         if not self.anyReady():
             self.pause()
             yield 1
开发者ID:casibbald,项目名称:kamaelia,代码行数:26,代码来源:Osc.py

示例3: all_handler

def all_handler(addr, tags, stuff, source):
    print "received new osc msg from %s" % OSC.getUrlStr(source)
    f_out.write(OSC.getUrlStr(source)+'; ')
    print "with addr : %s" % addr
    f_out.write(addr+'; ')
    print "typetags %s" % tags
    print "data %s" % stuff
    f_out.write(addr+'; ')
    f_out.write(str(stuff[0])+'; ')
    f_out.write(str(time.time())+'; ')
    f_out.write('humanreadable: '+datetime.fromtimestamp(int(time.time())).strftime('%Y-%m-%d %H:%M:%S'))
    f_out.write('\n')
开发者ID:jazoza,项目名称:connect-or-not-at-k4,代码行数:12,代码来源:log-osc-traffic-49999.py

示例4: all_handler

def all_handler(addr, tags, stuff, source):
    print "received new osc msg from %s" % OSC.getUrlStr(source)
    f_out.write(OSC.getUrlStr(source)+'; ')
    print "with addr : %s" % addr
    f_out.write(addr+'; ')
    print "typetags %s" % tags
    print "data %s" % stuff
    for smth in stuff:
        print smth
        f_out.write(str(smth))
        f_out.write('; ')
    f_out.write(str(time.time())+'; ')
    f_out.write('\n')
开发者ID:jazoza,项目名称:milicone,代码行数:13,代码来源:log-osc-traffic-49999.py

示例5: __init__

	def __init__(self, serport='/dev/ttyUSB0', scenefile=None, listenurl=':6788'):
		"""Instantiate DMXCtrl, instantiate OSCMultiClient & ThreadingOSCServer
		"""
		super(self.__class__, self).__init__(serport, scenefile)
		
		# parse 'listenurl' argument
		(addr, server_prefix) = OSC.parseUrlStr(listenurl)
		if addr != None and addr[0] != None:
			if addr[1] != None:
					listen_address = addr
			else:
					listen_address = (addr[0], default_port)
		else:
			listen_address = ('', default_port)
		
		# Create OSC Client & Server
		self.cli = OSC.OSCMultiClient()
		self.srv = OSC.ThreadingOSCServer(listen_address, self.cli)
		self.srv.addDefaultHandlers(server_prefix)
		self.srv.setSrvInfoPrefix("/serverinfo")
		
		# Register DMX-specific message-handlers
		self.srv.addMsgHandler(server_prefix + "/dmx/scene", self.dmxSceneHandler)
		self.srv.addMsgHandler(server_prefix + "/dmx/channel", self.dmxChanHandler)
			
		self.srv_thread = None
开发者ID:jpaalasm,项目名称:oscdmxctrl,代码行数:26,代码来源:dmxctrl.py

示例6: no_match_handler

 def no_match_handler(self,addr, tags, stuff, source):
     text=''
     text+= "no match for new osc msg from %s" % OSC.getUrlStr(source)+'\n'
     text+= "with addr : %s" % addr+'\n'
     text+= "typetags %s" % tags+'\n'
     text+= "data %s" % stuff+'\n'
     self.add_status(text+'\n')
开发者ID:athope,项目名称:pipresents-gapless,代码行数:7,代码来源:pp_oscremote.py

示例7: osc_printing_handler

 def osc_printing_handler(self, addr, tags, stuff, source):
     msg_string = "%s [%s] %s" % (addr, tags, str(stuff))
     sys.stdout.write("OSCServer Got: '%s' from %s\n" % (msg_string, OSC.getUrlStr(source)))
     # send a reply to the client.
     msg = OSC.OSCMessage("/printed")
     msg.append(msg_string)
     return msg
开发者ID:Vadiza,项目名称:sage-3.5b,代码行数:7,代码来源:soundUI.py

示例8: chew_data

def chew_data(host, port):
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    s.settimeout(0.05) # prevent blender from getting stuck if socket hangs
    s.bind((host, port))
    raw,addr = s.recvfrom(1024)
    o = OSC.decodeOSC(raw)
    return o 
开发者ID:conanxin,项目名称:Arduino-Meets-Blender-OSC,代码行数:7,代码来源:arduino_to_blender.py

示例9: heartbeat

def heartbeat(add, tags, stuff, source):
    global sw1
    cpu = psutil.cpu_percent()
    if sw1 == 1:
        # print "HEARTBEAT RECIEVED!"
        decoded = OSC.decodeOSC(stuff[0])
        # supercollider CPU usage and UGens printout
        cprint("CPU %/Number of Sounds: " + str(cpu) + "/" + str(decoded[3]), "red", attrs=["dark"])
        # scaling CPU values
        cpufloat = float(cpu)
        # print decoded[7]
        # ready the osc message
        oscmsg = OSC.OSCMessage()
        # determine which heartbeat to send
        if cpufloat < 2.0:
            oscmsg.setAddress("/heartbeat/faint")
        elif cpufloat < 6.0:
            oscmsg.setAddress("/heartbeat/weak")
        elif cpufloat < 10.0:
            oscmsg.setAddress("/heartbeat/medium")
        elif cpufloat < 20.0:
            oscmsg.setAddress("/heartbeat/strong")
        elif cpufloat < 30.0:
            oscmsg.setAddress("/heartbeat/heavy")
        else:
            oscmsg.setAddress("/heartbeat/intense")

            # adding the CPU usage value to the message, this can be mapped later.
        oscmsg.append(cpufloat)
        qlcclient.send(oscmsg)
        # sending CPU information back to SuperCollider
        oscmsg = OSC.OSCMessage()
        oscmsg.setAddress("/cpuinfo")
        oscmsg.append(cpufloat)
        scclient.send(oscmsg)
开发者ID:theseanco,项目名称:x201_dissection,代码行数:35,代码来源:020_ColouredPrinting.py

示例10: printing_handler

def printing_handler(addr, tags, stuff, source):
    print "---"
    print "received new osc msg from %s" % OSC.getUrlStr(source)
    print "with addr : %s" % addr
    print "typetags %s" % tags
    print "data %s" % stuff
    print "---"

    url="http://www.musicalturk.com/loops/add"
 

    shutil.move('/Users/Kleeb2/Documents/MaxPatches/MusicalTurk/'+ str(stuff[0]), "/Users/Kleeb2/Documents/Web/Python/Thesis/"+str(stuff[0])) 
    filename = str(stuff[0])
    #filename =  '/Users/Kleeb2/Documents/Web/Python/LocalThesis/max.py'
    title = 'test'#str(count).zfill(3)
    date = str(datetime.date.today()) 
    values = [('title', title), ('postedby',date)]
    try:
    	files = {'loop': open(filename, 'rb')}
    except:
    	print 'no file'
    try:
    	r = requests.post(url, files=files, data=values)
    	print r.text
    except:
    	print 'Fail'
开发者ID:markkleeb,项目名称:MusicalTurk,代码行数:26,代码来源:max.py

示例11: fader_handler

def fader_handler(addr, tags, data, source):
    print "---"
    print "received FADER new osc msg from %s" % OSC.getUrlStr(source)
    print "with addr : %s" % addr
    print "typetags %s" % tags
    print "data %s" % data
    split = addr.split("/")
    print "split", split
    # split[2] is nu faderx, we want the id
    fadernr = int(split[2][-1:])
    print "fadernr = ", fadernr
    # Add one and loop aftre we are at 5
    next_fader = (fadernr % 5) + 1
    return_addr = "/1/fader%s" % next_fader
    print "Return addres", return_addr
    msg = OSC.OSCMessage()
    msg.setAddress(return_addr)
    msg.append(data)
    c.send(msg)
    print "return message %s" % msg
    print "---"
    if 1 <= fadernr <= 4 and data[0] >= 0.5:
        msg = OSC.OSCMessage()
        toggle_addr = "/1/toggle%s" % fadernr
        msg.setAddress(toggle_addr)
        msg.append(1.0)
        c.send(msg)
        print "return message %s" % msg
    else:
        msg = OSC.OSCMessage()
        toggle_addr = "/1/toggle%s" % fadernr
        msg.setAddress(toggle_addr)
        msg.append(0.0)
        c.send(msg)
        print "return message %s" % msg
开发者ID:RoelAdriaans,项目名称:PyTouchOSC,代码行数:35,代码来源:pyosc1.py

示例12: _drop

 def _drop(self, message, addr, tags, packet, source, route=None):
     logging.debug("DROPPED (%s) from %s" % (message, OSC.getUrlStr(source)))
     logging.debug("\taddr: %s" % addr)
     logging.debug("\ttypetags: %s" % tags)
     logging.debug("\tdata: %s" % packet)
     if route:
         logging.debug("\troute: %s" % route)
开发者ID:baymax84,项目名称:SyncJams,代码行数:7,代码来源:syncjams.py

示例13: handle_root

def handle_root(addr, tags, data, source):
	print "---"
	print "received new osc msg from %s" % OSC.getUrlStr(source)
	print "with addr : %s" % addr
	print "typetags %s" % tags
	print "data %s" % data
	print "---"
开发者ID:benhinchley,项目名称:fiberlamp-hid,代码行数:7,代码来源:illuminator.py

示例14: countsHandler

def countsHandler(addr,tags,stuff,source):
    print '---'
    print 'new msg from %s' % OSC.getUrlStr(source)
    print 'with addr: %s' % addr
    print 'typetags %s' % tags
    print 'data %s' %stuff
    print '---'
开发者ID:compcore,项目名称:LaserVoting,代码行数:7,代码来源:server.py

示例15: printing_handler

def printing_handler(addr, tags, stuff, source):
    print "---"
    print "received from :  %s" % OSC.getUrlStr(source)
    print "with addr : %s" % addr
    print "typetags : %s" % tags
    print "data : %s" % stuff
    print "---"
开发者ID:alx-s,项目名称:ABCDerres,代码行数:7,代码来源:receive_OSC.py


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