I am currently working on a modular synth. I decided to create a Module class which inherits from AudioProcessor, and at the moment 2 class (VCO and SmartPan), which both inherit from the Module class.
I put 2 instances of the VCO module and 1 of the SmartPan module in an AudioProcessorGraph, using the addNode() method.
At the moment everything is working fine, but I am trying not to generate loops inside the graph. So I am trying to run Kahn’s algorythm (which checks if the graph has loops or not) after a connection is made, so that if it generate a loop, it’s possible to go back.
My question is: how can I copy the graph before adding the last connection to another AudioProcessorGraph? Should I just remove the last connection?
Also, I am declaring the graph in a “Rack.h” like this:
std::unique_ptr<juce::AudioProcessorGraph> chain; //as private member of a Rack class
I am inizializing it in the “Rack.cpp” constructor this way:
: chain(new juce::AudioProcessorGraph())
Am I doing everything correctly? I am able to call the chain->setPlayConfigDetails() method as well as prepareToPlay, processBlock and releaseResources methods.
I am still trying to resolve this problem. Alternatives to copying the intire graph are well accepted! Maybe I could add the last node as bypassed, test Kahn on the graph and if it has no loops set the bypass to false?
Thank you for the answer!
That’s actually what I discovered I could do, today! I made another Post about it: AudioProcessorGraph and loops with addConnection(). What's really happening?
I was afraid that adding a node that generates loops would call some assertions on the buffers (either read or write), or even worse, that the plugin would crash.
Well, I still don’t know how the AudioProcessorGraph already manages loops, but adding a node that generates one is not lethal, apparently. Checking if Kahn works after adding it to the graph while stuff’s playing is kinda dangerous, so I was trying to find a way of checking a copy of the graph that’s not actually connected. I guess it’s not necessary.