private void GetOutNames() { Console.WriteLine("Out Devices: "); MidiOutCaps caps = new MidiOutCaps(); for (int i = 0; i < WinMM.midiOutGetNumDevs(); i++) { WinMM.midiOutGetDevCaps(i, ref caps, Marshal.SizeOf(typeof(MidiOutCaps))); Console.WriteLine(caps.name); } }
private int GetOutIdByName(string deviceName) { MidiOutCaps caps = new MidiOutCaps(); int deviceID = -1; int num = WinMM.midiOutGetNumDevs(); for (int i = 0; i < num; i++) { WinMM.midiOutGetDevCaps(i, ref caps, Marshal.SizeOf(typeof(MidiOutCaps))); if (caps.name == deviceName) { deviceID = i; break; } } if (deviceID == -1) { throw new Exception("Midi OUT device " + deviceName + " not found"); } return(deviceID); }
internal static extern int midiOutGetDevCaps(int deviceId, ref MidiOutCaps caps, int sizeOfMidiOutCaps);