All right, I think I got this...
First, in the thread https://forum.bela.io/d/492-pd-crashes-with-osc which mentions mode switch errors (although it was probably for PD running on the desktop, here it is on the Bela), it is mentioned:
giuliomoro You are not meant to use sleep() inside the render() callback: that function is called at regular intervals depending on the block size and it needs to be done completely before the next time it is called. sleep() would make it overrun.
... and also:
I looked briefly at this patch, and indeed it attempts to remove sleep()
; so at first I thought there must be sleeps in udpreceive
or dumpOSC
, but it turns out, there aren't any. I think, the problem is actually described here https://forum.bela.io/d/594-udp-audio-over-ethernet :
giuliomoro Is the source for udp~ available anywhere? It turns out that netsend/netreceive/udpsend/udpreceive, do the networking I/O in the audio thread, which is completely crazy. If [udp~] believes similiarly, then that would require to be rewritten, otherwise you could just compile it for Bela.
Alternatively: on Bela I already rewrote [netsend] and [netreceive] so that they do the networking bits in a separate thread, so they are safe to use, so what about using this vanilla replacement for udp~?
Ah nice - so as my original setup for the mrpeach objects was [udpreceive PORT] -> [unpackOSC] -> [routeOSC /msg] -> [print]; I simply replaced [udpreceive PORT] with the PD vanilla object [netreceive -u -b PORT] ; note that -u
is required for UDP, and -b
is required for binary mode, which is what mrpeach's [unpackOSC] expects. All this works well on desktop - however, trying it on the Bela again gave me mode switch and underruns.
So, now the question was when where these objects ([netreceive], [netsend]) updated for the Bela. That posting is from 28 Jun 2018, and my Bela image is "Bela image, v0.3.1, 8 November 2017" - so apparently, I needed to update; this also was confirmed by the https://forum.bela.io/d/498-basic-netsend-netreceive thread.
So, as I did have a Bela git folder on my PC, I just did git pull
to bring the master branch to the latest, and then on the PC did:
Bela_git$ ./scripts/update_board -y
... and after a while the update completed. Restarted the Bela, and lo and behold - finally I get OSC messages in, without any mode switches and underruns - nice!
So eventually, I've used the vanilla-PD-but-modded-for-Bela [netreceive] object, the rest being the mrpeach objects [unpackOSC] and [routeOSC], in order to get this to work... Unfortunately, the splash screen on my updated Bela still shows "Bela image, v0.3.1, 8 November 2017", which might end up being confusing in the future. But at least, I have reception of UDP in a PD patch on the Bela without errors now, which is great.