grame-cncm / faust

Functional programming language for signal processing and sound synthesis
http://faust.grame.fr
Other
2.58k stars 322 forks source link

faust2bela : progam crash when the number of audio output of the dps is upper than bela audio output #836

Closed PascalFaivre closed 1 year ago

PascalFaivre commented 1 year ago

the cause is that the 'compute' function of mydsp assumes that the system has the same number of outputs. But the frame buffer passed to it is initialized only for outputs available on the system : gOutputs = new FAUSTFLOAT*[context->audioOutChannels]; for (unsigned int ch = 0; ch < context->audioOutChannels; ch++) { gOutputs[ch] = (float*)&context->audioOut[ch * context->audioFrames]; } By completing the frame buffer of ghostly outputs the program no longer crashes : unsigned int nbDspOutput = gDSP->getNumOutputs(); gOutputs = new FAUSTFLOAT*[nbDspOutput]; for (unsigned int ch = 0; ch < context->audioOutChannels; ch++) { gOutputs[ch] = (float*)&context->audioOut[ch * context->audioFrames]; } for (unsigned int ch = context->audioOutChannels; ch < nbDspOutput; ch++) { float* dummyframes = new float[context->audioFrames]; gOutputs[ch] = dummyframes; } It's probably the same thing with audio inputs. Would you a PR in this way ?

sletz commented 1 year ago

We have a dsp_adapter class that could be used for that. And you can find some use-cases like https://github.com/grame-cncm/faust/blob/10ea6212ca539c281fc2fd92da8ccb60ddeec560/architecture/faust/audio/rtaudio-dsp.h#L158 of other places in the repository.

PascalFaivre commented 1 year ago

yep, it's good news. I'll watch this