In the native implementation of MidiInDeviceProvider and MidiOutDeviceProvider for Linux, the implementation of nGetNumDevices doesn't distinguish between IN and OUT ports. Instead, it just counts the total number. This works as long as any MIDI port supports IN as well as OUT. This is quite common, but no guaranteed. If a port is only IN or only OUT, wrong values are returned for the number of ports.