Hi,

is there a way to turn on and off the audio engine of pure data on Bela?
Is there a function i could use in a pure data external to send the [; pd dsp $1( message?

    interesting question.....

    I was going to say, yeah, this is how i do it in MEC/Orac:
    https://github.com/TheTechnobear/MEC/blob/master/mec-kontrol/pd/kontrolrack/KontrolRack.cpp

    void KontrolRack_dspState(bool onoff) {
    #ifndef __COBALT__ 
        t_pd *pdSendObj = gensym("pd")->s_thing;;
        if (!pdSendObj) {
            post("KontrolRack_dspState: unable to find  pd to change dsp state to %d", onoff);
        } else {
            t_atom args[2];
            SETSYMBOL(&args[0], gensym("dsp"));
            SETFLOAT(&args[1], onoff);
            pd_forwardmess(pdSendObj, 2, args);
        }
    #endif
    }

    but as you can see, Ive explicitly disabled this for Bela...
    unfortunately, I can't remember doing this... my assumption is it must have crashed, so I disabled it.

    note:
    I send lots of pd messages around like this on bela and its fine, its just this one that is disabled.
    also it works fine on other platforms - its also possible libPD might be the culprit here.

      you should be able to, unless I made some ugly decision...

      klemenz Is there a function i could use in a pure data external to send the [; pd dsp $1( message?

      However, what do you want to achieve?

        thetechnobear
        thanks for that code snippet! I'll try it out.

        giuliomoro
        OK, how?!
        I am loading sofa files in a pure data external and that takes some time. When I want to change the sofa file it takes much longer then until the next DSP task. So that's why I want to turn off DSP while changing files and turn it on afterwards again to avoid underruns.

          klemenz underruns are not dangerous or bad, so it might be enough to mute audio to make them silent...(no crackles)

            lokki
            Well it is a problem. when i switch sofa files I get "1 mode switch detected on the audio thread!", "Underrun detected: … blocks dropped". When I try to switch again I get "Segmentation fault"

              klemenz . When I try to switch again I get "Segmentation fault"

              I am not sure how this could be related to switching DSP off and on. Could you send a minimal patch with clear instructions on how to reproduce the issue?

                giuliomoro
                You are right, the segmentation fault was my fault. I forgot to copy one sofa file into the directory.
                OK, I get mode switches and underruns but actually it's working. Only in pure data on my computer it is a bit annoying because it plays back the audio buffer while switching sofa files.
                You can find the project at: https://github.com/sofacoustics/SOFAlizer-for-pd

                klemenz i don't think the underruns are the problem then. there must be another reason. EDIT: sorry, i did only see now that @giuliomoro already responded

                When I try out the code from thetechnobear on my computer everything works fine.
                On Bela I get:
                Error in '/root/Bela/projects/SOFAlizer/SOFAlizer': corrupted double-linked list: 0x007df560
                Aborted
                make: *** [runide] Error 134
                Makefile:524: recipe for target 'runide' failed

                It occurs when I try to turn on dsp again.