示例#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 MidiProc(IntPtr hMidiIn, uint wMsg, UIntPtr dwInstance, UIntPtr dwParam1, UIntPtr dwParam2)
        {
            String StrEvent = "0x" + dwParam1.ToUInt32().ToString("X6");
            String StrdwP2  = "0x" + dwParam2.ToUInt32().ToString("X6");

            switch (wMsg)
            {
            case MIDIInEvent.MIM_DATA:
                KDMAPI.SendDirectData(dwParam1.ToUInt32());
                Task.Factory.StartNew(() => PrintEvent("MIM_DATA", StrEvent, Color.Lime));
                SetLastEvent(StrEvent, false);
                return;

            case MIDIInEvent.MIM_MOREDATA:
                KDMAPI.SendDirectDataNoBuf(dwParam1.ToUInt32());
                Task.Factory.StartNew(() => PrintEvent("MIM_MOREDATA", StrEvent, Color.OrangeRed));
                SetLastEvent(String.Format("SLOW {0}", StrEvent), false);
                return;

            case MIDIInEvent.MIM_LONGDATA:
                KDMAPI.SendDirectLongData(dwParam1);
                Task.Factory.StartNew(() => PrintEvent("MIM_LONGDATA", StrEvent, Color.MediumPurple));
                SetLastEvent(StrEvent, false);
                return;

            case MIDIInEvent.MIM_OPEN:
                SetLastEvent("MIM_OPEN", false);
                Task.Factory.StartNew(() => PrintEvent("MIM_OPEN", String.Format("P1: {0} - P2: {0}", StrEvent, StrdwP2), Color.MediumPurple));
                return;

            case MIDIInEvent.MIM_CLOSE:
                SetLastEvent("MIM_CLOSE", false);
                Task.Factory.StartNew(() => PrintEvent("MIM_CLOSE", String.Format("P1: {0} - P2: {0}", StrEvent, StrdwP2), Color.MediumPurple));
                return;

            case MIDIInEvent.MIM_ERROR:
                SetLastEvent(String.Format("MIM_ERROR {0}", StrEvent), true);
                Task.Factory.StartNew(() => PrintEvent("MIM_ERROR", StrEvent, Color.MediumPurple));
                return;

            case MIDIInEvent.MIM_LONGERROR:
                SetLastEvent(String.Format("MIM_LONGERROR {0}", StrEvent), true);
                Task.Factory.StartNew(() => PrintEvent("MIM_LONGERROR", StrEvent, Color.MediumPurple));
                return;

            default:
                SetLastEvent("MIM_UNK", true);
                return;
            }
        }
示例#3
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;
            }
        }
示例#4
0
        static void DoAnyway(String[] args)
        {
            try
            {
                DebugToConsole(false, "Started configurator.", null);

                if (!Functions.IsWindowsVistaOrNewer())
                {
                    MessageBox.Show("This version of the configurator won't work on Windows XP and older!", "OmniMIDI Configurator - FATAL ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                DebugToConsole(false, "Checking if driver is registered...", null);
                if (!CheckDriverStatusInReg("x86", clsid32))
                {
                    return;
                }
                if (Environment.Is64BitOperatingSystem)
                {
                    if (!CheckDriverStatusInReg("x64", clsid64))
                    {
                        return;
                    }
                }

                // Parse KDMAPI version
                Int32 Major = 0, Minor = 0, Build = 0, Revision = 0;
                if (Convert.ToBoolean(KDMAPI.ReturnKDMAPIVer(ref Major, ref Minor, ref Build, ref Revision)))
                {
                    KDMAPI.KDMAPIVer = String.Format("{0}.{1}.{2} (Revision {3})", Major, Minor, Build, Revision);
                }
                else
                {
                    MessageBox.Show("Failed to initialize KDMAPI!\n\nPress OK to quit.", "OmniMIDI ~ Configurator | FATAL ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Application.ExitThread();
                }

                Application.SetCompatibleTextRenderingDefault(false);

                int  runmode = 0;
                int  window  = 0;
                bool ok;

                BringToFrontMessage = WinAPI.RegisterWindowMessage("OmniMIDIConfiguratorToFront");
                m = new EventWaitHandle(false, EventResetMode.ManualReset, "OmniMIDIConfigurator", out ok);
                if (!ok)
                {
                    WinAPI.PostMessage((IntPtr)WinAPI.HWND_BROADCAST, BringToFrontMessage, IntPtr.Zero, IntPtr.Zero);
                    return;
                }

                TriggerDate();

                foreach (String s in args)
                {
                    if (s.ToLowerInvariant() == "/rei")
                    {
                        TLS12Enable(true);

                        FileVersionInfo Driver = FileVersionInfo.GetVersionInfo(UpdateSystem.UpdateFileVersion);

                        var current = Process.GetCurrentProcess();
                        Process.GetProcessesByName(current.ProcessName)
                        .Where(t => t.Id != current.Id)
                        .ToList()
                        .ForEach(t => t.Kill());

                        UpdateSystem.CheckForTLS12ThenUpdate(Driver.FileVersion, UpdateSystem.WIPE_SETTINGS);
                        return;
                    }
                    else if (s.ToLowerInvariant() == "/toomni")
                    {
                        UpdateToOmniMIDI();
                        return;
                    }
                    else if (s.ToLowerInvariant() == "/inf")
                    {
                        runmode = 2;
                        window  = 1;
                        break;
                    }

                    /*
                     * else if (s.ToLowerInvariant() == "/winmmdbg")
                     * {
                     *  runmode = 2;
                     *  window = 2;
                     *  break;
                     * }
                     */
                    else if (s.ToLowerInvariant() == "/egg")
                    {
                        CrashMyComputer.RtlAdjustPrivilege(19, true, false, ref CrashMyComputer.DummyBool);
                        CrashMyComputer.NtRaiseHardError(0xC01E0200, 0U, 0U, IntPtr.Zero, 6U, ref CrashMyComputer.DummyDWORD);
                        return;
                    }
                    else
                    {
                        runmode = 0;
                        window  = 0;
                        break;
                    }
                }

                TLS12Enable(false);

                if (Properties.Settings.Default.UpdateBranch == "choose")
                {
                    SelectBranch frm = new SelectBranch();
                    frm.ShowInTaskbar = true;
                    frm.StartPosition = FormStartPosition.CenterScreen;
                    frm.ShowDialog();
                    frm.Dispose();
                }

                ExecuteForm(runmode, args, m, window);
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format("Fatal error during the execution of the configurator!\nMore details: {0}\n\nPress OK to quit.", ex.ToString()), "OmniMIDI Configurator - FATAL ERROR", MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
        }
示例#5
0
        public InfoWindow()
        {
            InitializeComponent();

            VerLabel.Text = ReturnDriverAssemblyVersion(
                "OmniMIDI",
                "CR",
                new int[] { Driver.FileMajorPart, Driver.FileMinorPart, Driver.FileBuildPart, Driver.FilePrivatePart }
                );
            VerLabel.Cursor = Program.SystemHandCursor;

            BASSVer.Text = ReturnDriverAssemblyVersion(
                null,
                "U",
                new int[] { BASS.FileMajorPart, BASS.FileMinorPart, BASS.FileBuildPart, BASS.FilePrivatePart }
                );

            BASSMIDIVer.Text = ReturnDriverAssemblyVersion(
                null,
                "U",
                new int[] { BASSMIDI.FileMajorPart, BASSMIDI.FileMinorPart, BASSMIDI.FileBuildPart, BASSMIDI.FilePrivatePart }
                );

            int[] KDMAPIVerRef = { 0, 0, 0, 0 };
            if (KDMAPI.ReturnKDMAPIVer(ref KDMAPIVerRef[0], ref KDMAPIVerRef[1], ref KDMAPIVerRef[2], ref KDMAPIVerRef[3]) != 0)
            {
                KDMAPIVer.Text = ReturnDriverAssemblyVersion(
                    null,
                    "U",
                    KDMAPIVerRef
                    );
            }
            else
            {
                KDMAPIVer.Text = "N/A";
            }

            CopyrightLabel.Text = String.Format(CopyrightLabel.Text, DateTime.Today.Year);

            CurBranch.Text      = UpdateSystem.GetCurrentBranch();
            CurBranch.ForeColor = UpdateSystem.GetCurrentBranchColor();
            BranchToolTip.SetToolTip(CurBranch, UpdateSystem.GetCurrentBranchToolTip());
            if (Properties.Settings.Default.PreRelease)
            {
                VerLabel.Text += " (PR)";
            }

            OMBigLogo.Image =
                (DateTime.Today.Month == 4 && DateTime.Today.Day == 1) ? Properties.Resources.OMLauncherFish : Properties.Resources.OMLauncher;

            BB.Location  = new Point(OMBigLogo.Size.Width - BB.Size.Width - 8, OMBigLogo.Size.Height - BB.Size.Height - 8);
            BB.Parent    = OMBigLogo;
            BB.Image     = Properties.Resources.BB;
            BB.BackColor = Color.Transparent;

            BecomePatron.Cursor = Program.SystemHandCursor;
            BecomePatron.Image  = Properties.Resources.PatreonLogo;

            PayPalDonation.Cursor = Program.SystemHandCursor;
            PayPalDonation.Image  = Properties.Resources.PayPalLogo;

            GitHubPage.Cursor = Program.SystemHandCursor;
            GitHubPage.Image  = Properties.Resources.Octocat;

            OMLicense.Cursor = Program.SystemHandCursor;
            OMLicense.Image  = Properties.Resources.TextLogo;

            WinName.Text   = String.Format("{0}", OSInfo.Name.Replace("Microsoft ", ""));
            RAMAmount.Text = SoundFontListExtension.ReturnSoundFontSize(null, "ram", Convert.ToInt64((new ComputerInfo()).TotalPhysicalMemory));
            switch (Environment.OSVersion.Version.Major)
            {
            case 10:
                WinVer.Text = String.Format(
                    "Version {0} ({1})\nRelease {2}, Revision {3}",
                    WVerKey.GetValue("ReleaseId", 0).ToString(),
                    Environment.Is64BitOperatingSystem ? "64-bit" : "32-bit",
                    Environment.OSVersion.Version.Build,
                    WVerKey.GetValue("UBR", 0).ToString()
                    );
                break;

            case 6:
                if (Environment.OSVersion.Version.Minor > 1)
                {
                    WinVer.Text = String.Format(
                        "Version {0}.{1}\nBuild {2}",
                        Environment.OSVersion.Version.Major,
                        Environment.OSVersion.Version.Minor,
                        Environment.OSVersion.Version.Build
                        );
                }
                else
                {
                    if (Int32.Parse(Regex.Match(Environment.OSVersion.ServicePack, @"\d+").Value, NumberFormatInfo.InvariantInfo) > 0)
                    {
                        WinVer.Text = String.Format("{0}.{1}\nBuild {2}, Service Pack {3}",
                                                    Environment.OSVersion.Version.Major, Environment.OSVersion.Version.Minor,
                                                    Environment.OSVersion.Version.Build, Environment.OSVersion.ServicePack);
                    }
                    else
                    {
                        WinVer.Text = String.Format("{0}.{1}\nBuild {2}",
                                                    Environment.OSVersion.Version.Major, Environment.OSVersion.Version.Minor,
                                                    Environment.OSVersion.Version.Build);
                    }
                }
                break;
            }
        }