Prepare to play

I have a plug-in that seems to be exhibiting unusual behavior.

The playhead is playing, and I load the plug-in as an AU2…the prepare to play function is not called.

The plug-in then creates unusual crackling from not being initialized correctly.

…changing the DAWs sample rate, or other parameters like the audio driver, then triggers a call to prepare to play, and the issue resolves…

VST3 is fine.

Does anyone else have information regarding this?

Interesting. If this works as expected in VST3, but not AU, it could be something with the host. Which host(s) are you testing in?

I have not encountered such a problem myself, but I always put a check to make sure prepareToPlay() has been called before letting the processBlock process anything.
Just something simple like this could be good enough:
if(!prepared) return;
Where prepared is a bool initialized to false, and set to true after prepareToPlay() is called. (it should probably be an atomic bool).

This kind of code also helps verify that prepareToPlay() is the source of errors or not. “unusual crackling” that is fixed by a hard audio reset could be anything, including badly initialized buffers.

Yup, that would work.

I’ve only seen the behavior occur in Ableton, but I had fixed the problem before I moved on to testing with other hosts…

Glad to hear you fixed the problem.
In the interest of informing others who may be searching this forum in the future, what was the cause and solution to the issue?

So, the cause of this problem is unknown - (that’s why I posted on here - if anyone has any further information, please let us know) - as it seems to be symptomatic to AU2.

The solution is similar to yours - ensuring prepare to play is called one way or another…