Hi there,
I’m using an AudioProcessorGraph to build an FX chain with a few processors with their own editor.
I want the GUI of the individual processors to appear in the main FX chain window when selected. Initially I returned a new processorEditor when the processor was instantiated in the graph, however no GUI appears (although the processor was definitely instantiated).
I am now trying another method, where the createEditor method returns a nullptr for each of the node processors in the graph, and instead am using this helper function in the AudioProcessorGraph:
AudioProcessorEditor* getEditor(Node::Ptr node)
{
return node->getProcessor()->createEditor();
}
Then, in my main plugin editor, I have the following helper functions:
juce::Array<AudioProcessorEditor*> getEditors()
{
juce::Array<AudioProcessorEditor*> editors;
editors.add(processor.getEditor(processor.getNode1()));
editors.add(processor.getEditor(processor.getNode2()));
editors.add(processor.getEditor(processor.getNode3()));
return editors;
}
void setCurrentEditors()
{
currentEditors.clear();
currentEditors.add(processor.getEditor(processor.getNode1()));
currentEditors.add(processor.getEditor(processor.getNode2()));
currentEditors.add(processor.getEditor(processor.getNode3()));
}
void ObliqueConcreteV1AudioProcessorEditor::makeEditorsVisible(Rectangle<float>
box)
{
setCurrentEditors();
int prevWidth = 0;
int currWidth = (getWidth()/3) - 10;
for(int i = 0; i < getEditors().size(); i++)
{
auto editor = getEditors().getUnchecked(i);
auto currentEditor = currentEditors.getUnchecked(i);
if(editor->getName() == currentEditor->getName())
{
prevWidth = currWidth;
continue;
}
addAndMakeVisible(editor);
editor->setBounds((i+1) * prevWidth, box.getHeight() + 5, currWidth, box.getHeight() - 10);
prevWidth = currWidth;
}
}
calling setCurrentEditors causes the program to crash upon startup.
commenting out setCurrentEditors means the program runs fine, but means I cannot see the GUIs for the individual processors. Can anyone give insight into a better solution than what I’ve done or point out any errors with my logic?
Additional info: ThroughOutput is just a simple plugin that outputs the gain as it came in, implemented this as an alternative to an empty slot to ensure my Editor arrays never had nullptr values.
Any help appreciated.
Edit:
I should also add that each individual audio Processor works fine, the only difference being the instantiation of their Editors (using the above method instead of createEditor())