Retrieve the current selected MIDI input?

I have code that enables midi input which looks like this:

audioDeviceManager->setMidiInputEnabled(devices[1], true);

What I would like to do is pass the number of the MIDI device selected in the Audio Setting dialog window. Is there a method I can use to retrieve this number?

I guess you’d just find its name, and find the index of that string in the list of midi device names.

Of course, but how do I get the name of the selected midi device to compare with what’s in the list of devices returned by MidiOutput::getDevices()? Does the AudioDeviceManager class have a method for retrieving the MIDI device selected by the user?

It lets you get the current midi device, doesn’t it?

It lets you retrieve the current Audio Device but I don’t see any method in the docs for getting the current MIDI device. Perhaps it’s there but not documented?


Yup, if I wanted to get the default MIDI ‘output’ I would use that method. It’s the selected MIDI ‘input’ I am looking for?

Doh! Sorry, misread that… Well, no, because you can enable any number of midi inputs - there’s no concept of a “selected” one. You could go through them all and find out which ones are enabled?

Thanks Jules, I’ll try your suggestion.

Jules, why the asymmetry on inputs vs. outputs? That is, why is there only one selectable MIDI output, instead of any number, like the inputs?

Just because that’s how most people would want to use it, I guess. You might have a couple of different controllers, but won’t tend to play the same thing through more than one synth. If you need to do anything more complex, it’s easy enough to create the devices yourself.