processBlock called before prepareToPlay

Hi everyone,

I’m facing weird behaviour when adding plugins to the FL Studio Patcher: the processBlock function gets called before prepareToPlay. I’m not sure, but shouldn’t prepareToPlay always be called before starting the processing? In multiple plugins of mine I have crucial initialization stuff happening in the prepareToPlay function and calling processBlock before that leads to all kinds of undefined behaviour. Preventing this from happening is of course very simple but I guess what I’m asking is if the call order isn’t something to take for granted after all?

Best,
Aapo

Yes, if the host isn’t calling prepareToPlay before processBlock pretty much all existing plugins would fail quite badly, not only yours.

But… are you sure it isn’t called in FL Studio? I would imagine no one would be able to use that DAW if that’s the case. How are you debugging it?

Thanks for the reply. I am attaching Visual Studio to FL Studio and running the debug version of my plugins. In a normal mixer track erverything is called in normal order. In Patcher the issue arises when I have already dragged a node from input to output and then add the plugin to create parallel processing.

Now, I have not been able to find other plugins (from my limited collection) that crash in this same situation. It is pretty clear thought that the function calling is happening in a weird order since I fixed the issue by just adding a simple boolean that doesn’t let any processing to happen before prepareToPlay is called.

The original poster mentioned it’s happening in the patcher section of FL Studio and not generally while using FL Studio. Perhaps that isn’t a popular feature and people just haven’t noticed plugins malfunctioning in it?

Yes. If that’s the case it sounds like to me like a major FL Studio bug that should be reported ASAP.

Not processing anything unless prepareToPlay is called sounds like a decent temporary workaround though, that’s probably what I would do if I would ever run into that issue.

I see Nuendo calling prepareToPlay shortly before AND after starting audio callbacks. I added a lock which makes me very nervous but it’s only gonna get used once at about 3 buffers into processing.

Maybe your “bypass processing” bool is a safer idea, but it would mean outputting dry signal (or silence) for an entire buffer… or you’d have to check it before using every contentious object… but even that won’t be 100% safe.