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


Python OSC.readLong方法代码示例

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


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

示例1: decode

# 需要导入模块: import OSC [as 别名]
# 或者: from OSC import readLong [as 别名]
def decode(data):
    """Converts a typetagged OSC message to a Python list.
    modified for supercollider-specific messages.
    """
    table = { "i":OSC.readInt,
              "f":OSC.readFloat,
              "s":OSC.readString,
              "b":OSC.readBlob,
              "d":OSC.readDouble}
    decoded = []
    address,  rest = OSC.readString(data)
    typetags = ""
    
    if address == "#bundle":
        time, rest = OSC.readLong(rest)
        decoded.append(address)
        decoded.append(time)
        while len(rest)>0:
            length, rest = OSC.readInt(rest)
            decoded.append(OSC.decodeOSC(rest[:length]))
            rest = rest[length:]
          
    elif len(rest) > 0:
        typetags, rest = OSC.readString(rest)
        
        decoded.append(address)
        decoded.append(typetags)
        if(typetags[0] == ","):
            for tag in typetags[1:]:
               try:
                   value, rest = table[tag](rest)
                   decoded.append(value)
               except:
                   print "%s probably not in tags list" %tag
                   print "check scOSCMessage.py - def decodeSCOSC():"
        else:
            print "Oops, typetag lacks the magic ,"
    try:
        returnList = [decoded[0]]
    except IndexError:
        returnList = []
    try:
        oldRtnList = returnList
        returnList.extend(decoded[2:])
    except IndexError:
        returnList = oldRtnList
    return returnList
开发者ID:davk789,项目名称:sc-0.2,代码行数:49,代码来源:tools.py

示例2: parse_function

# 需要导入模块: import OSC [as 别名]
# 或者: from OSC import readLong [as 别名]
 def parse_function(self, data):
     # OSC.py uses big endian, OSC.readInt changed to little endian for p5osc
     address, rest   = OSC.readString(data)
     time, rest      = OSC.readLong(rest)
     length, rest    = self.readInt(rest)
     name, rest      = OSC.readString(rest)
     
     if name != "/p5glove_data":
         return
     
     junk, rest      = OSC.readString(rest)         
     a, rest    = self.readInt(rest)
     b, rest         = self.readInt(rest)
     c, rest         = self.readInt(rest)
     thumb, rest     = self.readInt(rest)
     index, rest     = self.readInt(rest)
     middle, rest    = self.readInt(rest)
     ring, rest      = self.readInt(rest)
     pinky, rest     = self.readInt(rest)
     x, rest         = self.readInt(rest)
     y, rest         = self.readInt(rest)
     z, rest         = self.readInt(rest)
     
     if self.initialized:
         self.dx = self.speed * (x - self.x_old)
         self.dy = self.speed * (y - self.y_old)
         self.dz = self.speed * (z - self.z_old)    
    
         # if hand is at least semi clenched, enable rotation
         if index > 30 and index > 30:
             self.tool_server.on_mouse_drag(0, 0, self.dx, -self.dy, 0, 0)
             self.tool_server.on_mouse_scroll(0, 0, 0, self.dz)  
     else:
         self.initialized = True
         
     self.x_old = x
     self.y_old = y
     self.z_old = z
开发者ID:cmorgan,项目名称:dypy,代码行数:40,代码来源:P5Device.py


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