I hit my head about it all day, read everything I could find, followed the source of the JDK, was not lucky to find out details about HOW or WHERE is looking for Java on a MIDI device and determines what is what.
I am trying to capture midi messages through the NI Audio 8 DJ MIDI IN port, but java does not βseeβ the MIDI IN port, but only the one that I successfully used to send midi. I also get the same results using the M-Audio USB UNO MIDI device: MidiSystem.getMidiDeviceInfo() only βseesβ the output port.
I checked the operation of the MIDI IN port with:
amidi -p hw:2,0 -d
and sending him some signals. It works great.
getMaxTransmitters() returns zero. MidiSystem.getMidiDeviceInfo() shows only one entry for both devices: Audio8DJ [hw:2,0] or Interface [hw:2,0]
The code below works fine for the receiver, and I think this is just the bit I need to check that getTransmitter() captures the port, since it works only for the other, and everything works fine, I get a MidiUnavailableException / Transmitter exception thrown .
I even took the getMaxReceivers() trap because I was just trying to see if the device only offered one entry and parsed it, but not.
public static Transmitter getMidiIn () { if (midiIn == null){ devices = MidiSystem.getMidiDeviceInfo(); for(MidiDevice.Info info: devices){ System.out.println("device class " + info.getClass()); MidiDevice device; try{ device = MidiSystem.getMidiDevice(info); if (info.toString().equals("Audio8DJ [hw:2,0]")){ if (device.getMaxTransmitters() != 0){ try{ device.open(); System.out.println("max transmitters:" + device.getMaxTransmitters()); midiIn = device.getTransmitter(); System.out.println("Found a transmitter: "+ midiIn); break; } catch (Exception e){ e.printStackTrace(); } } } } catch (MidiUnavailableException e1){ e1.printStackTrace(); } } } return midiIn; }
So, here is what I need here: alsa only lists one entry in amidi -l , and when I specify that as the port for the dump, it works fine. Java receives the same text and cannot sort MIDI IN by assigning it the class com.sun.media.sound.MidiOutDeviceProvider , so I wondered how to do this or where Java finds out what the device has to offer and why not? seeing the input port that alsa sees.
I am coding with eclipse Version: 3.8.1 IDE with JDK1.6, on Linux operating system.
I will be happy to provide everything that they ask. Thank you for reading!