Newb, AudioPluginHost & AUv3

Hey all… Just started poking around JUCE. Hoping to cobble together a simple project but got sidetracked with issues with AUv3 in the AudioPluginHost. I noticed that AudioPluginHost wasn’t re-instantiating AUv3’s when re-loading the prior session or loading a saved session. The AUv3 is properly saved in the .filtergraph file but is generating an error “This plug-in cannot be instantiated synchronously” while restoring the graph from the xml file.

Ok, so PluginGraph::restoreFromXml is creating plugins synchronously but AUv3’s need to be instantiated asynchronously. A few hacks later and I’m successfully restoring a filtergraph containing AUv3’s.

Then I tried opening one from the recent file list and run into this assert in AudioUnitPluginInstance::processAudio

    // If these are hit, we might allocate in the process block!
    jassert (buffer.getNumChannels() <= preparedChannels);

At first I thought it might be a race condition introduced to the async loading so tried suspending the audio graph but all that did was postpone the assert. More tracking and it seems like the second instantiation of the AUv3 isn’t being properly initialized because the preparedNodes cache in the audio processor graph isn’t being cleared when the graph is cleared causing the initialization to be skipped in NodeStates::applySettings. Simply adding a clear method to NodeStates and calling it seems to work.

And, damn, C++ sure has changed since I last used it.