belangeo / pyo-bela

Template to create a pyo project on the bela platform
GNU Lesser General Public License v3.0
12 stars 4 forks source link

Unable to run on Bela v0.3.2 #3

Closed jarmitage closed 6 years ago

jarmitage commented 6 years ago

Following the README as far as

root@bela:~/Bela/scripts# ./build_pyo.sh ../../pyo-bela/examples/music-box.py ../../pyo-bela/common/

Running /root/Bela/projects/music-box/music-box
Error: no audio callback defined. Make sure you set settings->render to point to your audio callback
Error: unable to initialise audio
Fatal Python error: PyEval_AcquireThread: NULL new thread state
Aborted
Makefile:504: recipe for target 'runonly' failed
make: *** [runonly] Error 134
Connection to 192.168.7.2 closed.

I'm guessing something has probably changed since v0.1.0a stable 2016.07.23? @giuliomoro

giuliomoro commented 6 years ago

You need to add three lines to the main.cpp file, as per this commit:

https://github.com/BelaPlatform/Bela/commit/8044c2d2702f7f5f039bf6fb9c1d1c299aafe072#diff-175a58b551ef8744df9a5c258d580f8f

Not sure why that main.cpp is needed anyhow, @belangeo ? Do you require the Bela blocksize to be 32?

If all you need is to specify some extra default settings, I'd recommend you get rid of the main.cpp file and set the default settings in a function void Bela_userSettings(BelaInitSettings *settings) inside render.cpp, e.g.:

void Bela_userSettings(BelaInitSettings *settings)
{
    settings->periodSize = 32;
    settings->numAnalogInChannels = 8;
    settings->numAnalogOutChannels = 8;
    settings->analogOutputsPersist = 0;
}

(the last setting was not included in @belangeo's main.cpp, but it saves a bit of memory copying, which could be helpful).

In case you are willing to re-factor slightly the code in render(), you could also add settings->uniformSampleRate = 1;, so that the analog channels are resampled in the backend and come into render() at the same rate as the audio channels.

Last, looking forward a couple of weeks to the release of Bela Mini, you want to make sure it all works fine when there are no analog out channels. In particular line

    pyo.analogout(context->analogOut);

in render.cpp will have to be conditionally excluded (as analogOut will be NULL). Not sure if this is going to break anything inside pyo though?

jarmitage commented 6 years ago

Can confirm that adding those three lines fixes, thanks

belangeo commented 6 years ago

All done! Thanks Giulio for the hints!