Hello, Firstly I’m new to JUCE and C++ and coding in general so this ay be a simple issue maybe not.
I’m messing around creating a plugin host plugin. so a Basic Plugin project that can host one plugin at a time. I understand the basic concepts I think so i know all the audio processing goes ion the PluginProcessor class and the GUI stuff in the PluginEditor class etc. I’ve managed to create a Plugin Instance and the associated editor but I’m stuck now. My understanding is I simply need to pass the buffer to the processBlock on the Plugin Instance and it should pass audio through the hosted plugin but although I am getting audio passing the gui doesnt seem to update with any meters moving and none of the knobs or parameters change the audio passing through. I’m pretty sure I’m missing something.
here the processor code to create the plugin instance
void HostModeAudioProcessor::loadPluginInstance(const PluginDescription& _pluginDescription)
{
if (_pluginDescription.name.isEmpty())
{
return;
}
auto* format = getFormatForDescription(_pluginDescription);
String err{};
double sampleRate = this->getSampleRate();
int blockSize = this->getBlockSize();
pluginInstance = format->createInstanceFromDescription(_pluginDescription, sampleRate, blockSize, err);
if (pluginInstance)
{
DBG("plugin Instance Created in Processor");
if (auto* editor = dynamic_cast<HostModeAudioProcessorEditor*>(getActiveEditor()))
{
editor->showPluginEditor();
}
}
else
{
std::cerr << "Failed to load plugin " << _pluginDescription.name << " : " << err
<< '\n';
}
}
and here’s the code to create the editor:
void HostModeAudioProcessorEditor::showPluginEditor()
{
if (HostModeAudioProcessor *processor = dynamic_cast<HostModeAudioProcessor*>(&audioProcessor))
{
if (AudioPluginInstance* pluginInstance = processor->getPluginInstance())
{
AudioProcessorEditor *editor = pluginInstance->createEditorIfNeeded();
if (editor)
{
pluginEditor.reset(editor);
pluginEditor->addComponentListener(this);
hostWindow.addAndMakeVisible(pluginEditor.get());
int pluginEditorWidth = pluginEditor->getWidth();
int pluginEditorHeight = pluginEditor->getHeight();
int borderSize = 5;
pluginEditor->setBounds(borderSize, 0, pluginEditorWidth, pluginEditorHeight);
hostWindow.setSize(pluginEditorWidth + (borderSize*2), pluginEditorHeight + (borderSize * 2));
setSize(pluginEditorWidth + (borderSize * 2), pluginEditorHeight + (borderSize * 2) + 50);
}
}
}
}
and my process block
void HostModeAudioProcessor::processBlock(juce::AudioBuffer<float>& buffer, juce::MidiBuffer& midiMessages)
{
juce::ScopedNoDenormals noDenormals;
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();
// Clear any output channels that don't have corresponding input channels
for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
{
buffer.clear(i, 0, buffer.getNumSamples());
}
// If a plugin instance is loaded, process audio through it
if (pluginInstance != nullptr)
{
pluginInstance->processBlock(buffer, midiMessages);
}
}
What am I missing. Its probably something obvious I know.
thanks for your help in advance.
