我可以创建包含通配符的OSC消息处理程序吗? [英] Can I create OSC message handlers containing wildcards?

查看:69
本文介绍了我可以创建包含通配符的OSC消息处理程序吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用pyosc创建OSC消息处理程序,该处理程序可以侦听来自TouchOSC的传入的多触发消息.

I am trying to create an OSC msg handler, using pyosc, which can listen to incoming multitoggle messages from TouchOSC.

多重切换是切换开关的网格.传入消息的格式为"/1/multitoggle1/5/8"或"/1/multitoggle1/x/y",其中x和y是与网格位置相对应的整数.

The multitoggle is a grid of toggleswitches. The incoming messages are in the form "/1/multitoggle1/5/8" or "/1/multitoggle1/x/y" where x and y are integers corresponding to the grid position.

server.addMsgHandler("/1/multitoggle1/5/8",toggle_callback)工作正常,但是我需要5和8作为在处理程序中读取的参数,因此无需添加单独的处理程序即可获取它们对于每个单独的切换.

server.addMsgHandler( "/1/multitoggle1/5/8", toggle_callback ) works fine but I need the 5 and the 8 to be arguments read in the handler so I can get at them without having to add a separate handler for each individual toggle.

s.addMsgHandler("/1/multitoggle1/",toggle_callback)似乎不起作用.

s.addMsgHandler( "/1/multitoggle1/", toggle_callback ) does not seem to work.

这一个类似的问题,但我无法实现隐含的解决方案.

It is a similar problem to this one but I can't implement the implied solution.

推荐答案

我遇到了同样的问题,这是我的解决方案:

I had the same problem and this was my solution:

for x in range(1,9):
    for y in range(1,6):
        s.addMsgHandler("/Channels/toggleChannels/"+`y`+"/"+`x`, toggleChannels)

def toggleChannels(addr,tags,data,source):
    split = addr.split("/")
    x = split.pop()
    y = split.pop()

我注册了所有处理程序,但只使用了一个回调,效果很好

I registered all handlers but used only one callback, worked great

这篇关于我可以创建包含通配符的OSC消息处理程序吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆