Loud pop when loading plugin

I’m finishing my first plugin in JUCE (a phaser). Sometimes, when I load the plugin (usually the first load after a new build), there’s a very loud pop. Sometimes this shuts down audio on that track (as in, any clips/regions playing do not output any sound, even if I remove the plugin from the insert chain), but usually it does not. This happens in both hosts I’m testing in (Logic and Ableton), but not the JUCE plugin host. I was wondering if anyone had any idea what might be causing this/ if this sounds symptomatic of something, as I have no idea where to start debugging this.

Sounds like an uninitialized variable to me, which affects the gain and is set after the first block (i.e. at the end of the processBlock).
Or you forgot to do a fade in at the beginning of processing. I usually have a lastGain variable initialized with 0 and use AudioBuffer::copyFromWithRamp(…)
Good Luck

I am initializing all of my values before they’re used, but I wasn’t applying a ramp. I’ve added a ramp to the first buffer that gets processed each time play is pressed, but this doesn’t fix it. Also, I should clarify- this is happening when I load the plugin with no audio playing/ the session being paused, and it’s much louder than when there’s a click between 2 disconnected waveforms.

I don’t know if it applies to all hosts, but they usually start processing as soon as the loading / instanciation is done.
This is e.g. because of monitoring, which starts immediately and switches when you push play/record to the suitable mode.
It doesn’t matter, if you push play or pause. the only thing that changes is, that playback or recording on the tracks start.

Without further details I can only guessing. I just want to add, that in >90% of cases alike, I found the error in my code, and these two problems were the most probable, but there are hundreds more…

Maybe somebody else has further ideas
Good Luck

Usually the pop comes from a variable not well initialized, which might be difficult to find. But something you can do already maybe is calling the processSamples a few times in the prepareToPlay function with an array of zeroes as an input… You might try also your plug-in in other DAWs such as Reaper to see if the problem really comes from your DAW or not.