Since AudioProcessorGraph is slow to buildRenderingSequence() due to it’s sort algorithm… I’m looking for a way to add and remove a batch of connections and only trigger buildRenderingSequence() at the end of the task.
I’ll probably write some code to add to my local copy of AudioProcessorGraph to create an OwnedArray of connections to add/remove and then trigger buildRenderingSequence() only after all the connections are changed…
Is this an addition you’d consider adding to the JUCE code?
My use-case is changing all my Mixer tracks’ outputs which means changing the connections for each track.
Okay a report back… I made the changes and it’s dramatically improved the profiling of my plug-in… Since I rarely just make a single connection at a time… I added methods to use OwnedArray::add() instead of OwnedArray::addSorted() and defer buildRenderingSequence() like:
bool AudioProcessorGraph::addConnectionUnsorted (const uint32 sourceNodeId,
const int sourceChannelIndex,
const uint32 destNodeId,
const int destChannelIndex)
const ScopedLock sl (buildLock);
if (! canConnect (sourceNodeId, sourceChannelIndex, destNodeId, destChannelIndex))
connections.add (new Connection (sourceNodeId, sourceChannelIndex, destNodeId, destChannelIndex));
After I make all the connections I call another new method:
For other methods I added an extra parameter with a default value for backward compatibility:
void AudioProcessorGraph::removeConnection (const int index, bool triggerUpdate /* = true */)
if (isPrepared && triggerUpdate)
(I did this for addNode() and removeNode() as well).
This change has reduced the time to reload a preset, where the connections are created dynamically, by more than 50% and made other functions in the plug-in much more responsive if they involve changing connections.
My testers have had it for 2 weeks with no reports of any issues.
I’ve also added another change to AudioProcessorGraph::Node to have a boolean class variable (named bypassed) which is used to easily bypass hosted plugins in the graph simply by changing the Node’s flag which is then checked in (float and double versions)