コード例 #1
0
        private void OmniMapperCpl_Load(object sender, EventArgs e)
        {
            try
            {
                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 (Functions.CheckMIDIMapper())
                {
                    bool   Found     = false;
                    String SelDevice = Program.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());
            }
        }
コード例 #2
0
        private void OmniMapperCpl_Load(object sender, EventArgs e)
        {
            try
            {
                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);

                String[] i386  = ReturnMIDIDevices("i386");
                String[] AMD64 = ReturnMIDIDevices("AMD64");
                String[] ARM64 = ReturnMIDIDevices("ARM64");

                foreach (String D in i386)
                {
                    var L = MDevs.FindIndex(x => x.PName == D);

                    if (L == -1)
                    {
                        MDevs.Add(new MIDIDevices()
                        {
                            PName = D, i386 = true, AMD64 = false, ARM64 = false
                        });
                    }
                    else
                    {
                        MDevs[L] = new MIDIDevices()
                        {
                            PName = D, i386 = true, AMD64 = MDevs[L].AMD64, ARM64 = MDevs[L].ARM64
                        }
                    };
                }

                foreach (String D in AMD64)
                {
                    var L = MDevs.FindIndex(x => x.PName == D);

                    if (L == -1)
                    {
                        MDevs.Add(new MIDIDevices()
                        {
                            PName = D, i386 = false, AMD64 = true, ARM64 = false
                        });
                    }
                    else
                    {
                        MDevs[L] = new MIDIDevices()
                        {
                            PName = D, i386 = MDevs[L].i386, AMD64 = true, ARM64 = MDevs[L].ARM64
                        }
                    };
                }

                foreach (String D in ARM64)
                {
                    var L = MDevs.FindIndex(x => x.PName == D);

                    if (L == -1)
                    {
                        MDevs.Add(new MIDIDevices()
                        {
                            PName = D, i386 = false, AMD64 = false, ARM64 = true
                        });
                    }
                    else
                    {
                        MDevs[L] = new MIDIDevices()
                        {
                            PName = D, i386 = MDevs[L].i386, AMD64 = MDevs[L].AMD64, ARM64 = true
                        }
                    };
                }

                foreach (MIDIDevices DV in MDevs)
                {
                    MIDIOutList.Items.Add(DV.PName);
                }

                if (Functions.CheckMIDIMapper())
                {
                    bool   Found     = false;
                    String SelDevice = Program.Mapper.GetValue("TrgtSynth", "Microsoft GS Wavetable Synth").ToString();
                    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());
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }