Pyo on the Bela works!

23 views
Skip to first unread message

Alexandros Drymonitis

unread,
May 21, 2026, 3:33:56 AMMay 21
to pyo-d...@googlegroups.com
I finally managed to get Pyo work on the Bela again and finalized the
necessary steps (one step less from what it used to be). There's a small
caveat with the settings.json file used by the Bela and I've posted
about this on Bela's forum. Once this is also settled, I'll update it on
my pyo-bela repository and I'll fork it for pyo-org. Unless Olivier
wants to update his pyo-bela repository through mine first and then I
fork his in pyo-org, like we did with the main pyo repo.

Chris Csikszentmihalyi

unread,
May 23, 2026, 12:58:54 PMMay 23
to pyo-d...@googlegroups.com
Alexandros, that is great news. Before digging out my Bela, can you confirm that midi/osc work without breaking the audio/event loop?

Chris Csíkszentmihályi
rob...@gmail.com | edgyproduct.org
"Art means… to resist the course of a world that unceasingly holds a gun to mankind's chest."    
                                                                  --Theodore Adorno


--
You received this message because you are subscribed to the Google Groups "pyo-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyo-discuss...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pyo-discuss/80041bf1-5b46-4bda-beb0-3c0114178399%40gmail.com.

Alexandros Drymonitis

unread,
May 23, 2026, 3:56:01 PMMay 23
to pyo-d...@googlegroups.com

I have to clarify that I made Pyo work on the Bela Gem stereo, their latest board that comes with their new IDE. There should be some small changes to make this work with the old Bela. I'll probably give it a shot this week and come back with results.

I haven't tested MIDI or OSC. For MIDI, I know that Pyo when hosted cannot handle it, so that has to be handled by the C++ side, correct? For OSC, how does that go? Can Pyo when hosted handle OSC?

Chris Csikszentmihalyi

unread,
May 23, 2026, 8:47:55 PMMay 23
to pyo-d...@googlegroups.com
Hi Alexandros,

It has been years, but I don't remember seeing information on Pyo-Bela documentation about hosting, or that midi/osc (and presumably other interfaces?) wouldn't work. So I spent a while on it, but got a sense that midi somehow took one out of an event loop / into user space somehow. Again, apologies as this was a long time ago, but I know there was a tool to see how quickly the event loop ran and it would go up an order of magnitude if one used that part of the library. I really don't remember seeing anything about hosting but I may have missed it.

I do think it would be good to have a clear set of info in the pyo-bela documentation saying what does and does not work. I'm happy to help with that, though I don't understand it yet.

Even looking in the PYO documentation quickly now, I couldn't find a clear definition of "hosting." Am I missing something? Thanks,

Chris.



--

Alexandros Drymonitis

unread,
May 24, 2026, 6:12:39 AMMay 24
to pyo-d...@googlegroups.com

The following text is taken from the m_pyo.h header file, which is used in all embedded projects:

When used in  an embedded framework, pyo can't open MIDI ports by itself. MIDI inputs must be handled by the host program and sent to pyo with the pyo_add_midi_event function.

So, MIDI is indeed handled by the host program. In the case of Bela, that would be C++. This means that PyoClass.cpp must be edited, because I just now looked and there's no call to this function. I'll deal with it this week and come back with updates.

Alexandros Drymonitis

unread,
May 24, 2026, 9:08:58 AMMay 24
to pyo-d...@googlegroups.com

I was actually wrong when I wrote that PyoClass.cpp doesn't contain a function to call pyo_add_midi_event() from m_pyo.h. I was looking at PyoClass.cpp of the openFrameworks example. In Bela, you can create a Pyo object (e.g. `Pyo pyo`) in your C++ file (this is what is done in the examples that come with Pyo-Bela), and then call `pyo.midiEvent(status, data1, data2);`. All arguments are ints.

In Bela, open the C++ MIDI example under "Communication" to see how to handle MIDI. Then check Pyo's documentation for the Server class, https://belangeo.github.io/pyo/api/classes/server.html#server, and read the `addMidiEvent` part, to see the status bytes you can send to `pyo.midiEvent()`. If you combine these, you'll probably get MIDI working on your Bela. I'll also give it a try and make an example to add it to the repository.

Olivier Bélanger

unread,
May 24, 2026, 12:05:56 PM (14 days ago) May 24
to pyo-d...@googlegroups.com
In embedded frameworks, it's usually the host program that handles i/o communications with the system (audio. midi, file, etc.), hence the addMidiEvent added to the Server class. OSC is a particular case of i/o in the sense that timing is not critical as with audio or midi. If liblo is installed on the bela board, compiling pyo with OSC enabled should just work. That would still need another argument to setup.py to enable OSC, but not Portaudio and Portmidi (it's all or nothing at the moment).

Olivier


Alexandros Drymonitis

unread,
May 24, 2026, 12:43:25 PM (14 days ago) May 24
to pyo-d...@googlegroups.com



On Sun, 24 May 2026, 19:05 Olivier Bélanger, <bela...@gmail.com> wrote:
In embedded frameworks, it's usually the host program that handles i/o communications with the system (audio. midi, file, etc.), hence the addMidiEvent added to the Server class. OSC is a particular case of i/o in the sense that timing is not critical as with audio or midi. If liblo is installed on the bela board, compiling pyo with OSC enabled should just work. That would still need another argument to setup.py to enable OSC, but not Portaudio and Portmidi (it's all or nothing at the moment).

Olivier
I can see if I can make this work. Just to be sure, Olivier, you have changed the way Pyo is compiled from calling setup.py to python - m build etc. Is this method still calling setup.py? Excuse my ignorance :) 

Olivier Bélanger

unread,
May 24, 2026, 3:05:15 PM (14 days ago) May 24
to pyo-d...@googlegroups.com
Here is how I compile on Debian (python 3.13):

python3 setup.py build_ext --inplace --use-jack [--use-double]
python3 -m build --wheel
python3 -m pip install --force-reinstall dist/pyo-*-cp313-cp313-linux_x86_64.whl

In the first line, I used to add --minimal to build without liblo (OSC), portaudio, and portmidi when building an embedded pyo.

Individual arguments could be added to offer more flexibility to decide which lib is supported, and which is not.

Olivier


Olivier


--
You received this message because you are subscribed to the Google Groups "pyo-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyo-discuss...@googlegroups.com.

Chris Csikszentmihalyi

unread,
May 26, 2026, 9:56:53 AM (12 days ago) May 26
to pyo-d...@googlegroups.com
Thanks so much, both of you. I am following along even if I can't help at the moment.

Chris Csíkszentmihályi
rob...@gmail.com | edgyproduct.org
"Art means… to resist the course of a world that unceasingly holds a gun to mankind's chest."    
                                                                  --Theodore Adorno


Alexandros Drymonitis

unread,
May 28, 2026, 11:35:42 AM (10 days ago) May 28
to pyo-d...@googlegroups.com

Some update on this. MIDI is quite tough to get it working. Using the NoteIn() class causes massive drop outs. Removing the class from the Python script, reduces the drop outs dramatically. After a couple of attempts, I was getting a crash with no sensible output, so I tried running the project with GDB from the terminal, but then it didn't crash...

As for OSC, liblo is not installed by default, and I think it's not a good idea to include in the README the process of installing it with apt in case someone wants to use OSC with Pyo on the Bela. If you want, you can work on the existing OSC examples that come with C++ and call PyoClass methods value() and set().

For now, I don't think that having MIDI support is feasible, but I'll see if I can get it working sometime in the near future again. If anyone else wants to jump in and try, you're welcome, of course.

Olivier Bélanger

unread,
May 28, 2026, 3:07:34 PM (10 days ago) May 28
to pyo-d...@googlegroups.com
Hi Alexandros,

You should not use the Notein, MidiCtl, etc. classes on the Bela. Instead you should retrieve the MIDI data in the C++ class and use the midi functions implemented in the Server to pass it to pyo (and compile pyo without portmidi support). 

Olivier

Aaron Krister Johnson

unread,
May 28, 2026, 4:11:29 PM (10 days ago) May 28
to pyo-d...@googlegroups.com
I've found MIDI in general on the Bela is iffy at best. YMMV....but IIRC the Xenomai Linux kernel has hard realtime requirements that don't play nicely with MIDI.



Alexandros Drymonitis

unread,
May 29, 2026, 4:48:39 AM (9 days ago) May 29
to pyo-d...@googlegroups.com
On 5/28/26 22:07, Olivier Bélanger wrote:
> Hi Alexandros,
>
> You should not use the Notein, MidiCtl, etc. classes on the Bela.
> Instead you should retrieve the MIDI data in the C++ class and use the
> midi functions implemented in the Server to pass it to pyo (and
> compile pyo without portmidi support).
I've copied the MIDI example that comes with the Pd examples in the
embedded section. In C++ I'm forwarding the MIDI messages to
`pyo.midievent()`. I have compiled Pyo with --minimal, so it shouldn't
have any midi support whatsoever. Is there something that you think is
wrong in this whole process?

barmin

unread,
May 29, 2026, 4:54:27 AM (9 days ago) May 29
to pyo-d...@googlegroups.com
I've tried to use the bela board as an fx box with pyo, but finally found it much easier to use a rpi instead. If you are curious about the details, I've described the whole setup in my EuroPython'25 talk: https://matthieuamiguet.ch/blog/europython25-talk-online/

It works great, with an audio roundtrip latency way under 10ms, and MIDI and OSC working without problem.

Matthieu

Le 28.05.26 à 22:11, Aaron Krister Johnson a écrit :
Reply all
Reply to author
Forward
0 new messages