Custom DSP and changing channel count on attachment

Hi all,

Writing a custom DSP that needs a pre-allocated buffer (one per output channel count). For example, if this custom DSP was attached to a 2 channel ChannelControl object, we would need to pre-allocate 2 buffers. 5.1, we would need to allocate 6 buffers.

It appears that you only get the create callback once, when the DSP is created. When you are trying to “attach” to a ChannelControl, there is no callback, or any allocation or setup you can do before the read callback is called.

Is there any way to do setup like this? It’s obviously unsafe to do in the audio thread. Is our only option creating/destroying the custom dsp so it calls “create” again?

I was looking for something like an “attach” or “detach” callback, but that doesn’t seem to exist.

Thanks for the help.

For the record, our architecture is extremely similar to the code found in fmod/core_api/examples/dsp_custom.cpp

Any resources that are channel count dependent will need to be pre-allocated for the highest expected channel count during create or deferred to the audio thread (read / process), which is the first point you can see what the actual incoming channel count is.

Isn’t allocating on the audio thread risky? It’s a non-deterministic system call.

It’d be nice to be able to know this information before the audio callback came. I am still a newbie to FMOD, but in the audio plug-in world in JUCE there is a callback called PrepareToPlay that gives this info before the processing starts.

It’s not ideal but due to the flexible nature of channel counts with the FMOD DSP structure you must pre-allocate or perform a mixer thread allocation. This is something I’m actively looking into for our significant DSP architecture improvements underway for 2.03.