Пример #1
0
        private void RefreshInputs_Click(object sender, EventArgs e)
        {
            // Check count
            DeviceCount = WinMM.midiInGetNumDevs();
            if (DeviceCount < 1)
            {
                // None available, close
                MessageBox.Show("No MIDI input devices available.", "OmniMIDI - Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Close();
                return;
            }

            // Initialize KDMAPI
            if (sender == null)
            {
                if (!Convert.ToBoolean(KDMAPI.InitializeKDMAPIStream()))
                {
                    MessageBox.Show("Unable to initialize KDMAPI.", "OmniMIDI - Fatal error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Close();
                    return;
                }

                KDMAPI.ResetKDMAPIStream();
            }

            // Initialize MIDI inputs list
            MIDIINCAPS InCaps = new MIDIINCAPS();

            MIDIInList.Items.Clear();
            for (uint i = 0; i < DeviceCount; i++)
            {
                WinMM.midiInGetDevCaps(i, out InCaps, (uint)Marshal.SizeOf(InCaps));
                MIDIInList.Items.Add(InCaps.szPname);
            }
        }
Пример #2
0
        private void Refreshdev_Click(object sender, EventArgs e)
        {
            int OutCount = WinMM.midiOutGetNumDevs();
            int IntCount = WinMM.midiInGetNumDevs();

            OutCombo.Items.Clear();
            for (uint i = 0; i < OutCount; i++)
            {
                MIDIOUTCAPS MidiDev;
                if (WinMM.midiOutGetDevCaps(i, out MidiDev, (uint)Marshal.SizeOf(typeof(MIDIOUTCAPS))) == 0)
                {
                    OutCombo.Items.Add(MidiDev.szPname);
                    OutCombo.Enabled = true;
                }
            }

            InCombo.Items.Clear();
            for (uint i = 0; i < IntCount; i++)
            {
                MIDIINCAPS MidiDev;
                if (WinMM.midiInGetDevCaps(i, out MidiDev, (uint)Marshal.SizeOf(typeof(MIDIINCAPS))) == 0)
                {
                    InCombo.Items.Add(MidiDev.szPname);
                    InCombo.Enabled = true;
                }
            }
        }