示例#1
0
        private int GetInIdByName(string deviceName)
        {
            MidiInCaps caps     = new MidiInCaps();
            int        deviceID = -1;
            int        num      = WinMM.midiInGetNumDevs();

            if (num == 0)
            {
                throw new Exception("There are no midi IN devices");
            }
            int capSize = Marshal.SizeOf(typeof(MidiInCaps));

            for (int i = 0; i < num; i++)
            {
                if (WinMM.midiInGetDevCaps(i, ref caps, capSize) != 0)
                {
                    throw new Exception("Cannot get midi IN device with ID " + i);
                }
                if (caps.name == deviceName)
                {
                    deviceID = i;
                    break;
                }
            }
            if (deviceID == -1)
            {
                throw new Exception("Midi IN device " + deviceName + " not found");
            }
            return(deviceID);
        }
示例#2
0
        private void GetInNames()
        {
            Console.WriteLine("In Devices: ");
            MidiInCaps caps = new MidiInCaps();

            for (int i = 0; i < WinMM.midiInGetNumDevs(); i++)
            {
                WinMM.midiInGetDevCaps(i, ref caps, Marshal.SizeOf(typeof(MidiInCaps)));
                Console.WriteLine(caps.name);
            }
        }