[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sc-users] [OT] pyOSC question



Hi all

I'm sorry for posting an off-topic question, but there doesn't seem to be an official palce to ask pyOSC questions and I thought there might be some expertise here.

I'm writing a Python program that will intercommunicate with SuperCollider via OSC. I originally started using pyliblo, but I realised that it doesn't quite meet my needs (there's no way to remove a callback once it's been added), so I've switched to pyOSC.

My question is, in pyOSC, how can I filter messages by OSC type tags? It seems from the example code that callbacks are added with something like

server.addMsgHandler("/my/path", callback_func)

but then callback_func has to know how to handle an OSC message of any format, e.g.

['/my/path', 1.0]
['/my/path', 42, 64, 6.283]
['/my/path', "foo", "bar", "baz"]
etc.

This seems to mean that I have to put error checking code in every single callback, to make sure that the message has the right format, which is very annoying. But then again, there's a lot of stuff in pyOSC that isn't demonstrated in the example code, so I wondered whether anyone knows of a better way?

Nathaniel


-- 
Nathaniel Virgo
http://nathanielvirgo.com