private void GetAndParseMidiOutCaps() { // Prepare parameters IntPtr pId = (IntPtr)Id; NativeMethods.MIDIOUTCAPS caps = new NativeMethods.MIDIOUTCAPS(); uint sz = (uint)Marshal.SizeOf(typeof(NativeMethods.MIDIOUTCAPS)); // Call native function NativeMethods.midiOutGetDevCaps(pId, caps, sz); // Parse results ManufacturerId = caps.wMid; ProductId = caps.wPid; Name = caps.szPname; Technology = (ETechnology)caps.wTechnology; MaxVoices = caps.wVoices; MaxNotes = caps.wNotes; ChannelMask = caps.wChannelMask; DriverVersion = String.Format("{0}.{1}", caps.vDriverVersion >> 8, caps.vDriverVersion & 0xff); }
public void listOutputDevices() { int numberOfDevices = NativeMethods.midiOutGetNumDevs(); outputDeviceNames.Clear(); if (numberOfDevices > 0) { for (Int32 i = 0; i < numberOfDevices; i++) { NativeMethods.MIDIOUTCAPS caps = new NativeMethods.MIDIOUTCAPS(); if (NativeMethods.midiOutGetDevCaps(i, ref caps, (UInt32)Marshal.SizeOf(caps)) == NativeMethods.MMSYSERR_NOERROR) { string pname = caps.szPname; Console.Out.WriteLine("Found output device #" + i + ": " + pname); outputDeviceNames.Add(pname); } } } }
public static DeviceCaps GetDeviceInfo(int id) { var devCaps = new NativeMethods.MIDIOUTCAPS(); if (NativeMethods.midiOutGetDevCaps((uint)id, ref devCaps, (uint)Marshal.SizeOf(typeof(NativeMethods.MIDIOUTCAPS))) != NativeMethods.MMSYSERR_NOERROR) return null; var caps = new DeviceCaps(); caps.deviceName = devCaps.szPname; return caps; }