About AudioProcessorGraph, probably stupid question


i started building a plugin with the default structure of the Audio plugin project with a PluginProcessor.h, PluginProcessor.cpp and same for PluginEditor.h and PluginEditor.cpp, now i need an AudioProcessorGraph with 1 node that process before, and 1 node that process after, so what right now is in PluginProcessor should be the center node out of 3, my question is: do i have to create the AudioProcessorGraph externally and use for example:

graph->addNode(new MyPluginProcessorClassName());

or could be done in a simpler way by creating the AudioProcessorGraph inside the PluginProcessor and call the center node like this?:


Thx in advance



I don’t think your plugin’s main AudioProcessor should be part of the audioprocessor graph…

You probably should arrange things so that the plugin’s main AudioProcessor just owns and handles the AudioProcessorGraph. The functionality you want to put into your “center” node would be implemented in a separate AudioProcessor subclass.



If you don’t plan to change the processing chain at runtime, you can save a lot of pain, if you simply call the processors one after each other:

void processBlock (const AudioBuffer<float>& buffer, MidiBuffer& midi)
    proc1.processBlock (buffer, midi);
    proc2.processBlock (buffer, midi);
    proc3.processBlock (buffer, midi);

or even better, use the dsp::ProcessorChain



I see, so what right now is the main processor should just become an external processor ane be hosted from the graph that is outside, i was scared of that since the editor manage already many things of the processor and i wanted it to manage also the other processors hosting, but if the Graph is outside probably can’t access it, i will have to change the plugin structure i guess, thx for your clarification :slight_smile:



Thx for answering daniel, basically what i want to do in more details is to have my plugin that now is entirely in my PluginProcessor, and have 2 vst instance, 1 pre processing and 1 post processing, so i was thinking to make a graph and host the 2 vst pre and post in the first node and third node of the graph keeping the center node the Processor where now is my plugin, ofc if that could be done by creating the graph inside the processor so that i can call easily and manage it from the Editor, would save lot of work i guess,

the example that you did calling the processblock in chain is what i was hoping for, my question was infact if i can create the graph the should launch them inside the class proc2 and host it by creting the node like that proc2->addNode(this);



Ok, after a rough test seems to be working (even tho i feel is a bit of a dirty solution) to create another Clean processor with just the graph in it and some public functions that manage the processors hosting, and set it as main, it will host immediately the node of the real processor and create the editor like this:

graph->addNode(new myPluginProcessor());
editor = graph->getNode(correspondentNode)->getProcessor()->createEditor(); //editor is declared public

then in the editor of the graph in the constructor i overlap myPluginProcessor editor:


this overlap myPluginProcessorEditor over the graph Editor, and from it i will access the public functions to host the nodes in the graph processor, since i tested it only in a new project, just to test the logic, i hope nothing will explode when i actually do it in the real project :stuck_out_tongue: