1

I'm listing all MIDI devices in a combobox, but for the loopback drivers I get duplicate entries.

  • The first entries don't work and contain no description ( getDescription() returns "No details available" )
  • The others, which are the working ones, return "External MIDI Port" description.

Now, I would like to know why rtpMidi, LoopBE, LoopMidi and all loopback drivers cause these duplicate entries, so that I can exclude them from the list in a secure way. I could simply avoid the entries without a valid description, but I don't like acting without knowing the reason why those entries are reported in the first place. Another thing that puzzles me is that if I try filtering the results via "if(dev instanceof Receiver)" I get a blank list, the same with instanceof Transmitter, Synthesizer and Sequencer. So it seems like none of the midi devices are instance of one of those classes, but only instance of MidiDevice class, which doesn't help me with filtering the list... Could someone please suggest a different solution?

// Get MIDI device list
info = MidiSystem.getMidiDeviceInfo();
device = new ArrayList<MidiDevice>();
deviceDetails = new ArrayList<String>();
int j=0;
for (int i = 0; i < info.length; i++) {
    MidiDevice dev = MidiSystem.getMidiDevice(info[i]);

    //if ( dev instanceof Receiver ) { // tried Receiver, Transmitter, Synthesizer and Sequencer

        // Detailed List
        deviceDetails.add("Device ID: " + j);
        deviceDetails.set(j, deviceDetails.get(j) + "\nName: " + info[i].getName());
        deviceDetails.set(j, deviceDetails.get(j) + "\nDescription: " + info[i].getDescription());
        device.add(dev);
        deviceDetails.set(j, deviceDetails.get(j) + "\nDevice: " + device.get(j));
        //Combo Box (Dev names only)
        MidiOutCombo.add(info[i].getName());
        j++;
    //}
}

Here's the temporary solution I found, it works but it's string-based and I don't know if it works crossplatform...

if (info[i].getDescription().compareTo("External MIDI Port") == 0 ) {

1 Answer 1

0

Loopback drivers typically have two ports, one for receiving, and one for transmitting.

To determine if a MIDIDevice has any receivers or transmitters, you must call its getMaxReceivers/getMaxTransmitters methods.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.