I’ve created a PluginWrapper that allows the loaded plugin to be swapped, based on the ideas here:
https://github.com/getdunne/juce-wrapper
Note that those code examples are somewhat old and had to be modified.
But the basic thing I added, after getting the wrapper working, was how to swap out the loaded plugin:
void PluginWrapper ::replacePlugin(std::unique_ptr<AudioPluginInstance> newPlugin)
{
suspendProcessing (true);
// replace the std:unique_ptr
plugin = std::move (newPlugin);
prepareToPlay(sampleRate, bufferSize);
suspendProcessing (false);
};
From the place where you have created the new plugin, you have a std::unique_ptr, I call it like this:
plugWrapper->replacePlugin(std::move (instance));
It seems to work…
