Multiple MIDI Devices with the AudioProcessorGraph


#1

Hi
This is, as usual probably very simple for the experienced Jucers but I need some guidance:
If you have a AudioProcessorGraph and a Player, like in the HostDemo, You can route MIDI from hardware inputs just like audio.
As far as I have figured out the common way of doing this is by adding a AudioGraphIOProcessor node with the IODeviceType set to midiInputNode.

Now, how do you know which actual MIDI device the messages are coming from?
If you enable two midi devices, can you send messages from MIDI device 1 to node A and device 2 to node B?

Is this possible out of the box or would I need to create my own AudioGraphIOProcessors?

As far as I can tell from looking through the classes, the only place where you can filter messages by device (in a setup like this) is in handleIncomingMidiMessage in AudioProcessorPlayer.

Anyone else done this and found a clever way?


#2

Anyone got any bright ideas?


#3

There is only one global midi channel as far as the graph is concerned.  You might want to try MidiMessage getChannel().  I haven't done much midi stuff but I'm guessing the channel data that you're looking for is passed in with the midi data and not as separate device channels like for audio streams.


#4

If you want to have control over specific connections from multiple MIDI devices, your best bet is to wrap each MIDI device in its own subclass of juce::AudioProcessor.


#5

Second that, although I’d subclass the AudioProcessorGraph to accomodate for this and auto-populate the input device processors.


#6

Thank you guys!

Then I'm already on the right track. I was just affraid that I was missing something in the docs.

I have created midi input and midi output processors, that I add in my custom graph.

This also serves as a nice layer between the actuall hardware device and what the user selects in the app.


#7

I’m trying desperately to understand this wonderful library and specific topic…If I subclass AudioProcessorGraph so that i can filter out MIDI messages for a single specific MIDI input device, and I have multiple instances of AudioProcessorGraphs; one for each MIDI input device each of which will feed a VSTi plugin, how do I… 1.) combine the audio outputs for each separate graph into a single (ASIO) audio output device?..2.) “drive” / trigger the separate AudoProcessorGraphs to process MIDI input and send that to the VSTi plugins?

I’ve tried a few experiments all of which have failed miserably in trying to separate two MIDI input keyboards destined for two separate VSTis…both of which should be merged to a single audio output device.

I’d be happy to share incorrect code I’ve tried so far. Trying to understand this but I’m only about three months into using JUCE.


#8

Please ignore my last post in this thread…I must be having “one of those” days.

i just reset my MIDI controllers, did a clean build and everything works! I didn’t even need to subclass AudioGraphProcessor with the current JUCE 5.0.2 code.

Sharing object usage here in case this helps anyone else with this topic. (If there’s a better way please let me know!)

One AudioDeviceManager instance which connects to my ASIO audio output.
Three AudioProcessorPlayer Objects - one for each instrument, plus a master to drive the device manager.
Three AudioProcessorGraph Objects - one for each instrument, plus a master to combine / connect them.

Add a master audio in and out to the master AudioProcessorGraph.

Add an audio output and MIDI input to each instrument AudioProcessorGraph

Wire it all up correctly with addConnection calls.

it works! i shocked myself! Willing to share code if anyone wants it but I’m still sorting out leaking objects myself.

I know I’ve said this before but I L O V E JUCE!