I’m building a setup using the AudioProcessorGraph and I’m just wondering about the best way to mix all the nodes output together.
A simple version is I have a bunch of separate samplers (based on the Synthesizer class), wrapped in AudioProcessor’s, inserted into a graph but it seems in their processBlock methods the buffer is just the main buffer. If each synth clears the buffer (like in the juce demo code) it clears what the previous synth has written. If I don’t clear the buffer there is garbage in it. It works if the first sampler clears the buffer in it’s processBlock and the rest just add to it but that doesn’t seem the right way to do it. (especially when putting graphs in graphs etc.)
AudioProcessorGraph graph; AudioProcessorGraph::Node *midi_generator = audio_processor_graph.addNode( new MidiGenerator() ); AudioProcessorGraph::Node *simple_sampler_node = audio_processor_graph.addNode( new MySampler() ); AudioProcessorGraph::Node *simple_sampler_node_2 = audio_processor_graph.addNode( new MySampler() ); AudioProcessorGraph::Node *output = audio_processor_graph.addNode( new AudioProcessorGraph::AudioGraphIOProcessor(AudioProcessorGraph::AudioGraphIOProcessor::audioOutputNode) ); //...Connect the midi_generator to the samplers //...Connect the samplers to a graph output //...Connect AudioProcessorPlayer to Device manager etc. (you get the idea, the sound works so no probs here)
In this setup only the second sampler will sound if I clear the buffer in the sampler node, or if I don’t clear the buffer I get garbage.
I sort of assumed the AudioProcessorGraph has some kind of process for mixing things but is the correct approach to create my own ‘mixer’ node that would provide separate buffers to the Sampler nodes and then sum them? Is the AudioProcessorGraph made to work with parallel chains like this or do I have to add that functionality?