Strange Bug or am I confusing sth?


#1

Hey,
when I call MidiInput::getDevices() my Midi Device is Called “MyDevice MIDI: MyDevice MIDI MIDI 1”. When I open a AudioDeviceSelectorComponent it lists the Device as “MyDevice MIDI MIDI 1” (without “MyDevice MIDI:”), and writes it like that in the xml (as i want too). But If I load this xml, its not working, it needs “MyDevice MIDI: MyDevice MIDI MIDI 1” in the xml! If I change it by hand (Add “MyDevice MIDI:” by hand in the xml) it works again.

aplaymidi -l gives

Port Client name Port name
14:0 Midi Through Midi Through Port-0
28:0 MyDevice MIDI MyDevice MIDI MIDI 1

So it seems like on time it is taking client and port name, and one time just the portname.

mhh!

greetz equinox


#2

I’m not quite getting the problem you have, but it’s probably the same problem I had a while ago. I tried to fix it in the JUCE code, but I think I realized that it was an unsolvable problem, and added a workaround to my own code instead, explained below.

To load an output MIDI device given a name, I do this:

#if defined(FOR_LINUX)
  if (name.startsWith(JUCE_ALSA_MIDI_OUTPUT_NAME + ": "))
    name = name.substring(String(JUCE_ALSA_MIDI_OUTPUT_NAME + ": ").length());
#endif

  StringArray devices = MidiOutput::getDevices();

  int device_id = devices.indexOf(name);
  if (device_id==-1){
#if JUCE_WINDOWS
     return NULL;
#else
     return MidiOutput::createNewDevice(device_id);
#endif
  } else {
    return MidiOutput::openDevice(device_id);
  }

And the same for opening a MIDI input device, just change JUCE_ALSA_MIDI_OUTPUT_NAME to JUCE_ALSA_MIDI_INPUT_NAME.