Weird inititialization behavior of VST versus AU


Hi all:

I am running into a problem with my copy protection code, where my copy protection function seems to be called once for Audio Units, but 3 times for VSTs. I have found that I can reproduce the issue with the Juce Demo Plugin.

Here’s how to reproduce the bug:

  • In the constructor function for the GUI (PluginEditor.cpp, JuceDemoPluginAudioProcessorEditor::JuceDemoPluginAudioProcessorEditor) add the following code:

AlertWindow::showMessageBox (AlertWindow::NoIcon, "Test Window", "Let's see how often this is called.", "OK");

So, why would this be called once for an Audio Unit, but 3 times for a VST?

Also, is the constructor of the GUI the best place for my copy protection function to be called from? The plugin constructor itself results in my copy protection being called when the host starts up, which is annoying. I tried putting it in prepareForPlay(), which works for Audio Units, but causes VSTs to hang the host.

Thanks for the help,

Sean Costello


You shouldn’t make any assumptions about when your objects will be created or destroyed, the host may do this at any time. E.g. if the host asks how big the editor is, but doesn’t actually want to display it, then the only way is for the wrapper to create one, get its size and then delete it.

The constructor and prepareToPlay are both bad choices for anything that may take a long time. Personally, I’d do it on a timer (if it won’t block for a noticeable amount of time), or a background thread.


My quick fix is to put a bool in my Audio Processor class, set it to false in the Audio Processor constructor, and then check to see if it is false when calling my alert window in my Editor constructor. If it is false, call the alert window, and set the bool to true. Hackish, to be sure, but it works fine.