public MidiSystem() { //input devices int deviceID; uint incount = midiInGetNumDevs(); inputDevices = new List <InputDevice>(); MIDIINCAPS inCaps = new MIDIINCAPS(); for (deviceID = 0; deviceID < incount; deviceID++) { MMRESULT result = midiInGetDevCaps(deviceID, ref inCaps, Marshal.SizeOf(inCaps)); //if we get an error, just skip the device if (result == MMRESULT.MMSYSERR_NOERROR) { InputDevice indev = new InputDevice(deviceID, inCaps.szPname); inputDevices.Add(indev); } } //output devices uint outcount = midiOutGetNumDevs(); outputDevices = new List <OutputDevice>((int)outcount); MIDIOUTCAPS outCaps = new MIDIOUTCAPS(); for (deviceID = 0; deviceID < outcount; deviceID++) { MMRESULT result = midiOutGetDevCaps(deviceID, ref outCaps, Marshal.SizeOf(outCaps)); //if we get an error, just skip the device if (result == MMRESULT.MMSYSERR_NOERROR) { OutputDevice outdev = new OutputDevice(deviceID, outCaps.szPname); outputDevices.Add(outdev); } } }
static extern MMRESULT midiInGetDevCaps(int uDeviceID, ref MIDIINCAPS caps, int cbMidiInCaps);