There doesn’t appear to be any way to get midi output from AudioProcessorGraph. The processBlock method for an AudioGraphIOProcessor with an IODeviceType of midiOutputNode copies outbound MidiMessages to a private member, currentMidiOutputBuffer, in AudioProcessorGraph. However, neither AudioProcessorGraph nor AudioGraphIOProcessor provides a way to access this buffer.
To get around this, I added a public method to AudioProcessorGraph to access this buffer:
I then output the midi in the processBlock of a class derived from
AudioProcessorGraph* graph = dynamic_cast<AudioProcessorGraph*>(this->getCurrentProcessor());
double time = Time::getMillisecondCounterHiRes() /*+ numSamples * secondsPerSample */;
getMidiOut()->sendBlockOfMessages(graph->getMidiOutputBuffer(), time, samplesPerSecond);
Is there is a better way to do this, perhaps without modifying any of the supplied Juce classes? There seems to be a glaring hole in implementation AudioProcessorGraph (and, incidently, in the plug-host which lacks a midi-out internal plug-in, though it has the other three: audioIn, audioOut, and midiIn). However, I couldn’t turn up any complaints about it in a search of the forum which leads me to believe I may be missing the whole concept of how to do midi out when using the AudioProcessor classes.
Also note the commented out code in calculating the second argument to sendBlockOfMessages. It doesn’t seem to make much difference if I leave it commented out or not. Any insights into what the value to this argument should be would be greatly appreciated.