Open Sound Control (OSC) is a protocol for communication among computers, sound synthesizers, and other multimedia devices that is optimized for modern networking technology. It is particularly common to use OSC with MAX/MSP -- which in fact is what I am doing, using OSC with Python to talk to another subsystem in MAX.
There are a bunch of python modules that support OSC. Great. And they all claim to be simple, useful, and perfect. At the risk of verging into subjective territory, what use cases does your experience suggest for the following modules?
I suppose a simple implementation would serve me best since I have only a glancing familiarity with OSC. And I'm using Python 2.7.
For anyone else who runs across this stackoverflow question every time they're looking for a python OSC implementation and who needs a working OSC implementation for Python 3 – I can confirm that osc4py3 works well and is well documented.
My survey results from Jan 22 2018:
pyOSC: does not seem to be maintained and I could not find a working Python3 version, some links I found to versions that claimed to be updated for python3 were broken.
aiosc: worked in testing (and seemed like a cool implementation) but for some reason it failed with a "Too many open files" error after a few seconds at the bandwidth I needed.
osc4py3: installed with pip, worked well, and gave me zero problems with around a thousand messages per second, as long as I made sure to call osc_process() after every message.
There may be another OSC version out there that is especially well designed for py3k and that more people are using, but since the field is still a little opaque I felt like this is probably the most appropriate place to share this. I hope it saves someone else a little time.
I have used pyOSC with great success on OSX. The code isn't under much development but this is most likely due to it's stability and simplicity. I briefly tried txosc and it may warrant further testing.
My usage of pyosc is limited but it works well. eg.
import OSC
c = OSC.OSCClient()
c.connect(('127.0.0.1', 57120)) # connect to SuperCollider
oscmsg = OSC.OSCMessage()
oscmsg.setAddress("/startup")
oscmsg.append('HELLO')
c.send(oscmsg)
This isn't exactly what the question asked, but I think it's something worth mentioning here: one annoying thing about the various Python OSC modules is that most work with either Python 2.x or with Python 3.x but not with both, which means that you might have to change code base and rewrite part of your app in the future.
The only one I found that targets both Python 2.x and 3.x is Pyliblo, which is actually a wrapper for the C library Liblo. Liblo has been specifically tested to work with Pd and SuperCollider (see note at the end of its main page), which is what I mostly cared about when using such libraries... A downside of Liblo is that it's a bit harder to get working on MS Windows because it supports only POSIX threads (pthreads) but not the native win32 thread API, so you need an emulation library as explained at http://liblo.sourceforge.net/README-platforms.html. But you can also compile it with threading disabled on Windows.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With