Clear Connections from AudioProcessorGraph? removeConnection not working as expected

Would it be possible to add to AudioProcessorGraph:

OwnedArray<Connection>& getConnections () { return connections; }

I mainly need this because, for some reason this does not work:

        for (int i = 0; i < audioProcessorGraph->getNumConnections(); ++i)

I get errors when trying to reconnect as the connection is still present.

But (with the above method added) this does:


This issue would also be addressed by a clearConnections method.

Maybe there is some other way to achieve what I’m trying to do? Basically, clearing all connections so that the graph nodes can be reconnected according to changed user settings.

Not sure about removeConnection(), but I usually abstract all connection configs as XML. When needed, I call graph->clear() to wipe them before I traverse my XML data for new/modified connections. I’m using more or less the same code as used in the host demo for loading and unload patches. I just removed the bits I didn’t need.

Thanks, I’ll take a look at that approach. So you are storing your AudioProcessorGraph as XML?

That’s right. Before I make any life changing modifications I just grab a snapshot in XML. It was more of a diagnostic thing when I started, but it worked so well I decided to see how it would fair in managing my graph. So far so good but I’m dealing with rather simple graphs. I’ve no idea how well this would work with a graph of 20 or more nodes.

If you step through… In AudioProcessorGraph::removeConnection() is isPrepared true?

If not I have a suggested addition to AudioProcessorGraph which adds a public method:

void refreshGraph() { triggerAsyncUpdate(); }

You can then simply call refreshGraph() after removing your connections.


Stepping through, I see that isPrepared is true, and triggerAsyncUpdate is called. So not sure why the connections are not actually removed?

EDIT: This seems to be working now… must have been something else going in my graph.

Update: This seems to only be partially working, and unreliable; looping through all connections and called removeConnection only seems to work some of the time. So I’ve gone back to my hack of exposing the connections array for now.

I’ll try and get a basic example project together to show the issue, when I get some spare time…