Thank you all for your input.
Indeed, checking the device names is the easiest way to go but not very reliable, I have a Korg Triton Ex and a Korg Pa1000 and they both have the suffixes “KEYBOARD” for input port and “SOUND” for the output.
Meanwhile, the range of Keyboards I’m looking to target with my app is somewhat limited, I can probably hard code all the names in some helper class, but then, what if I have 2 keyboards of the same model hooked at the same time? That would create some confusion! Unless the system magically distinguishes them from each other by adding an enumeration or something like that, but I have no means to test this unless I buy another Pa1000 and wait for my divorce papers
I have been looking around and found a neat trick in this open source project:
The problem is that I am new to c++ and this code goes way over my head but what I could understand is the following:
The FindSynthOnMidiNetwork.cpp class inherits from a thread and does the following in the run() method:
- Open’s all MidiIns and hooks a callback to them.
- Loops over the MidiOutputs and…
- Send’s a device Id request sysex to the MidiOut device one by one
- Listens for the callback which has a MidiInput parameter
- the replying MidiInput gets associated with the tested MidiOutput
I am still trying to decipher the code though as the project is a bit complicated with a lot if moving parts. If one of you gurus can help simplify this to fit into my little brain with a simpler example I would be greatly thankful. Also, I am hoping I can refresh my device list on the fly if a new device gets hooked up or removed.