I want to share my experience with a multiprocessor version of audio-processor graph, i think its a good start to build an “official” version for juce/T4.
My version uses the same method names as the original version, so it should no big problem to replace it with the original version.
I think is a good idea to create an abstract version of AudioProcessorGraph/Node, than it would be easy to switch between a single- and multicore version.
Basic data-structures like connections could be inherited. (the friend-class relationship with “Node” is may not elegant for inheritance)
Up to now i ignored all midi-functionality, so it may not work properly with midi. Also there is a recursion-check for the graph missing.
It uses a simple self organizing, but tested and good working structure, based on the “ideal” assumption that every node has its own CPU.
Because you never now, when a AudioProcesser has completed its block-processing, most pre-sorting of processing-operations would be redundant.
Thats why i have chosen this structure.
Basically the worker threads (number of CPUs-1) just iterate through the audioProcesser-nodes and look what they “can do”.
“node=nodes_workingCopy[ (++nextNodeIteritater) % nodes_workingCopy.size() ];”
The AudioDevice-Callback-Thread also do processing, but never! does any OS-implicied waiting (like WaitableEvent/Sleep)
Every node has references to other nodes, which are connected via inputs and outputs, and uses a atomic number to stores its “numberOfProcessedInputs”.
After a node has processed (“AudioProcessorGraphMultiProcessor::Node::process()”) it increase the “numberOfProcessedInputs” of nodes which are connected via outputs.
So when a the “numberOfProcessedInputs” reached “requiredInputs.size()” , the worker-thread collects all audio-input-data into the nodes own audio-buffer and does the processing.
The orginal AudioProcessorgraph uses MM-Callback-locks to prevent threading issues, instead i use the critical Section “reconfigurationLock” to make it safe for any thread to call a method.
New file location: