Would anyone happen to know the proper procedure to load a plugin while getNextAudioBlock is running?
void loadPluginChannel(int file_index, int track)
{
// shutdownAudio();
if (plugins[track])
{
basicWindow[track]->removeFromDesktop();
plugins[track]->releaseResources();
plugins[track].reset();
}
track_slected = track;
pluginmanager.addDefaultFormats();
descs.clear();
// the single .vst3 file may have multiple plugin types, so we need to deal with an array
// of PluginDescriptions
juce::VST3PluginFormat v3format;
v3format.findAllTypesForFile(descs, plugin_file[file_index]);
if (descs.size() > 0)
{
plugins[track] = pluginmanager.createPluginInstance(*descs[0], sampleRateHost, samplesPerBlock, error);
if (!plugins[track])
{
//plugins.insert(0, (pluginmanager.createPluginInstance(*descs[0], 44100, 512, error)));
//std::cout << error << "\n";
}
else
{
error_message = descs[0]->descriptiveName;
numOutputChannels = plugins[track]->getNumOutputChannels();
plugins[track]->enableAllBuses();
audioprocessoreditor = plugins[track]->createEditor();
bounds = audioprocessoreditor->getBounds();
basicWindow[track] = new BasicWindow(descs[0]->descriptiveName, juce::Colours::black, 7, true);
//basicWindow->setBounds(720, 280, 600, 400);
basicWindow[track]->centreWithSize(bounds.getWidth(), bounds.getHeight());
basicWindow[track]->setContentComponent(audioprocessoreditor, false);
basicWindow[track]->setVisible(true);
plugins[track]->prepareToPlay(sampleRateHost, samplesPerBlock);
}
}
// setAudioChannels(2, 2);
}
This Code works but its crashing when I try to load another plugin over the top.
Any help would be appreciated.