Frage

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.

War es hilfreich?

Lösung 2

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)

Andere Tipps

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.

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.

I've been using pyOSC for years... and "I was there" when it migrated from Python 2 to 3. Well... if I don't remember well, I asked the maintainer in that moment (Artem Baguinski) to do it!

Now, there're two pages that host pyOSC... and, regarding to your question, one of the pages (the oldest) host Python2 version. And the one in Github (that it is old, too, and not developed any more), the Python3 version.

I'm not sure of pyOSC versions, because OSC.py changelog says nothing about Python version. Maybe it was not correctly docummented.

pyOSC 0.3.5 (Python2): https://trac.v2.nl/wiki/pyOSC

pyOSC 0.3.6 (Python3): https://github.com/ptone/pyosc

As ptr said, it's very easy to implement. I use to connect Blender Game Engine with PureData.

I just want to mention that i recently started a new implementation, with the aim of clean code and support for python2.7 and python3 (only tested 3.6, but the core code doesn't use anything specific to it). One can find it at https://pypi.org/project/oscpy/ and https://github.com/kivy/oscpy if you are interested, i was careful about keeping the code clean and documented. It's MIT licensed.

I've used python-osc 1.7.4 w/ Python 3.8 to implement an OSC to tpm2.net gateway on Windows 10.

Granted, I've only been using it for 2 days, and it was the first one I tried (I just picked one that said it supported py3, that had recent commits, and a decent example).. but it worked fine with no issues...

The only thing is, in the README.md it says it supports OSC 1.0, and they're up to 1.1, but for me that was not an issue.

https://github.com/attwad/python-osc

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top