示例#1
0
        private void MidiDisconnectA_Click(object sender, EventArgs e)
        {
            int res = WinMM.midiDisconnect(hMidiIn, hMidiOut, IntPtr.Zero);

            if (res != 0)
            {
                MessageBox.Show(String.Format("Failed to execute midiDisconnect.\nError: {0}", res), "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
示例#2
0
        private void MIDIInList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (handle != IntPtr.Zero)
            {
                WinMM.midiInStop(handle);
                WinMM.midiInClose(handle);
            }

            midiInProc = new WinMM.MidiInProc(MidiProc);
            int retval = WinMM.midiInOpen(out handle, MIDIInList.SelectedIndex, midiInProc, IntPtr.Zero, WinMM.CALLBACK_FUNCTION);

            WinMM.midiInStart(handle);
        }
示例#3
0
        private void StopMIDIIn_Click(object sender, EventArgs e)
        {
            int res = WinMM.midiInClose(hMidiIn);

            if (res != 0)
            {
                MessageBox.Show(String.Format("Failed to close MIDI in device.\nError: {0}", res), "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                hMidiIn = IntPtr.Zero;
            }
        }
示例#4
0
        protected override void OnFormClosing(FormClosingEventArgs e)
        {
            base.OnFormClosing(e);

            if (handle != IntPtr.Zero)
            {
                WinMM.midiInStop(handle);
                WinMM.midiInClose(handle);
            }

            mut.WaitOne();
            mut.ReleaseMutex();
            mut.Close();

            KDMAPI.TerminateKDMAPIStream();

            if (e.CloseReason == CloseReason.WindowsShutDown)
            {
                return;
            }
        }
示例#5
0
        private void InitMIDIIn_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(InCombo.Text))
            {
                MessageBox.Show("No device selected", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (hMidiIn != IntPtr.Zero)
            {
                MessageBox.Show("There's already a device allocated now.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            int res = WinMM.midiInOpen(out hMidiIn, InCombo.SelectedIndex, null, IntPtr.Zero, 0);

            if (res != 0)
            {
                MessageBox.Show(String.Format("Failed to open MIDI in device.\nError: {0}", res), "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#6
0
        private void MidiConnectA_Click(object sender, EventArgs e)
        {
            if (hMidiOut == IntPtr.Zero)
            {
                MessageBox.Show("No MIDI out device has been initialized.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (hMidiIn == IntPtr.Zero)
            {
                MessageBox.Show("No MIDI in device has been initialized.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            int res = WinMM.midiConnect(hMidiIn, hMidiOut, IntPtr.Zero);

            if (res != 0)
            {
                MessageBox.Show(String.Format("Failed to execute midiConnect.\nError: {0}", res), "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
示例#7
0
 public OmniMapperCpl()
 {
     InitializeComponent();
     DeviceCount = WinMM.midiOutGetNumDevs();
 }
示例#8
0
        private void OmniMapperCpl_Load(object sender, EventArgs e)
        {
            try
            {
                RegistryKey CLSID = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows NT\CurrentVersion\Drivers32", false);
                bool        OmniMapperInstalled = (CLSID.GetValue("midimapper", "midimap.dll").ToString() == "OmniMIDI\\OmniMapper.dll");
                CLSID.Close();

                ActiveMovieKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\ActiveMovie\devenum\{4EFE2452-168A-11D1-BC76-00C04FB9453B}\Default MidiOut Device", true);
                MIDIMapperKey  = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Multimedia\MIDIMap", true);

                MIDIOUTCAPS OutCaps = new MIDIOUTCAPS();
                for (uint i = 0; i < DeviceCount; i++)
                {
                    WinMM.midiOutGetDevCaps(i, out OutCaps, (uint)Marshal.SizeOf(OutCaps));
                    if (OutCaps.szPname.Equals("OmniMapper"))
                    {
                        continue;
                    }

                    MIDIOutList.Items.Add(OutCaps.szPname);
                }

                if (OmniMapperInstalled)
                {
                    bool   Found     = false;
                    String SelDevice = OmniMIDIConfiguratorMain.Mapper.GetValue("TrgtSynth", "Microsoft GS Wavetable Synth").ToString();
                    CurDevice.Text = String.Format(CurDrvLab, SelDevice);
                    for (int i = 0; i < MIDIOutList.Items.Count; i++)
                    {
                        if (MIDIOutList.Items[i].ToString().Equals(SelDevice))
                        {
                            MIDIOutList.SelectedIndex = i;
                            Found = true;
                            break;
                        }
                    }

                    if (!Found)
                    {
                        MIDIOutList.SelectedIndex = 0;
                    }
                }
                else
                {
                    Text = String.Format("Change {0} settings", Functions.IsWindows8OrLater() ? "Windows Media Player MIDI output" : "MIDI mapper");
                    if (ActiveMovieKey != null)
                    {
                        MIDIOutList.SelectedIndex = Convert.ToInt32(ActiveMovieKey.GetValue("MidiOutId"));
                    }
                    else
                    {
                        MIDIOutList.SelectedIndex = MIDIOutList.FindStringExact(MIDIMapperKey.GetValue("szPname", "Microsoft GS Wavetable Synth").ToString());
                    }
                    CurDevice.Text = String.Format(CurDrvLab, MIDIOutList.Items[MIDIOutList.SelectedIndex].ToString());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }