From 6e123449f2d11a3253e8eff978d6b31e39fca334 Mon Sep 17 00:00:00 2001 From: FredTheHunter Date: Fri, 8 Mar 2024 14:45:33 -0500 Subject: [PATCH 1/9] feat : added a checkbox in the sound config menu of emuhawk to mute the app when minimized --- .gitignore | 2 + firmware.zip | 0 lua.zip | 0 .../Sound/Utilities/BufferedAsync.cs | 1 + src/BizHawk.Client.Common/config/Config.cs | 2 + src/BizHawk.Client.EmuHawk/MainForm.cs | 11 + src/BizHawk.Client.EmuHawk/Program.cs | 6 + src/BizHawk.Client.EmuHawk/Sound/Sound.cs | 6 + .../config/SoundConfig.Designer.cs | 644 ++++++++++-------- .../config/SoundConfig.cs | 8 + 10 files changed, 378 insertions(+), 302 deletions(-) create mode 100644 firmware.zip create mode 100644 lua.zip diff --git a/.gitignore b/.gitignore index 0922affde82..44bb7c1f855 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,5 @@ /packages launchSettings.json + +/Dist/copyBIOS.sh diff --git a/firmware.zip b/firmware.zip new file mode 100644 index 00000000000..e69de29bb2d diff --git a/lua.zip b/lua.zip new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/BizHawk.Client.Common/Sound/Utilities/BufferedAsync.cs b/src/BizHawk.Client.Common/Sound/Utilities/BufferedAsync.cs index 14795ab8978..0349c4c90a0 100644 --- a/src/BizHawk.Client.Common/Sound/Utilities/BufferedAsync.cs +++ b/src/BizHawk.Client.Common/Sound/Utilities/BufferedAsync.cs @@ -45,6 +45,7 @@ public sealed class BufferedAsync : ISoundProvider, IBufferedSoundProvider /// public void RecalculateMagic(double framerate) { + // TODO-me : might be useful! // ceiling instead of floor here is very important (magic) SamplesInOneFrame = 2 * (int)Math.Ceiling((44100.0 / framerate)); //TargetExtraSamples = ;// complete guess diff --git a/src/BizHawk.Client.Common/config/Config.cs b/src/BizHawk.Client.Common/config/Config.cs index 37cb1fe179e..8e9173f6336 100644 --- a/src/BizHawk.Client.Common/config/Config.cs +++ b/src/BizHawk.Client.Common/config/Config.cs @@ -255,6 +255,8 @@ public void ResolveDefaults() public string SoundDevice { get; set; } = ""; public int SoundBufferSizeMs { get; set; } = 100; + public bool MuteInBG { get; set; } = false; + // Lua public RecentFiles RecentLua { get; set; } = new RecentFiles(8); public RecentFiles RecentLuaSession { get; set; } = new RecentFiles(8); diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index 8a6d3c9aa8c..f9725002b38 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -3301,8 +3301,19 @@ private void StepRunLoop_Core(bool force = false) // Tools will want to be updated after rewind (load state), but we only need to manually do this if we did not frame advance. UpdateToolsAfter(); } + if(Config.MuteInBG) { + if(WindowState == FormWindowState.Minimized) { + Sound.StopSound(); + } + else { + Sound.StartSound(); + } + } else { + Sound.StartSound(); + } Sound.UpdateSound(atten, DisableSecondaryThrottling); + } private void CalcFramerateAndUpdateDisplay(long currentTimestamp, bool isRewinding, bool isFastForwarding) diff --git a/src/BizHawk.Client.EmuHawk/Program.cs b/src/BizHawk.Client.EmuHawk/Program.cs index 88eaf12f71e..0fb5f0f97da 100644 --- a/src/BizHawk.Client.EmuHawk/Program.cs +++ b/src/BizHawk.Client.EmuHawk/Program.cs @@ -31,8 +31,13 @@ internal static class Program static Program() { // This needs to be done before the warnings/errors show up + Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); + + + + // Quickly check if the user is running this as a 32 bit process somehow // TODO: We may want to remove this sometime, EmuHawk should be able to run somewhat as 32 bit if the user really wants to @@ -89,6 +94,7 @@ static Program() private static int Main(string[] args) { var exitCode = SubMain(args); + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { Console.WriteLine("BizHawk has completed its shutdown routines, killing process..."); diff --git a/src/BizHawk.Client.EmuHawk/Sound/Sound.cs b/src/BizHawk.Client.EmuHawk/Sound/Sound.cs index fe4886b5312..cac25ba4f0e 100644 --- a/src/BizHawk.Client.EmuHawk/Sound/Sound.cs +++ b/src/BizHawk.Client.EmuHawk/Sound/Sound.cs @@ -51,6 +51,7 @@ public Sound(IntPtr mainWindowHandle, Config config, Func getCoreVsyncRa { _outputDevice = config.SoundOutputMethod switch { + // TODO-me : Vérifier ici. ESoundOutputMethod.DirectSound => new DirectSoundSoundOutput(this, mainWindowHandle, config.SoundDevice), ESoundOutputMethod.XAudio2 => new XAudio2SoundOutput(this, config.SoundDevice), ESoundOutputMethod.OpenAL => new OpenALSoundOutput(this, config.SoundDevice), @@ -60,6 +61,7 @@ public Sound(IntPtr mainWindowHandle, Config config, Func getCoreVsyncRa } /// + /// TODO-me : Might be interesting /// The maximum number of milliseconds the sound output buffer can go below full before causing a noticeable sound interruption. /// public int SoundMaxBufferDeficitMs { get; set; } @@ -127,6 +129,7 @@ public void SetInputPin(ISoundProvider source) } else if (source.SyncMode == SyncSoundMode.Async) { + // TODO-me : RecalculateMagic could be interesting _bufferedAsync.RecalculateMagic(_getCoreVsyncRateCallback()); _bufferedProvider = _bufferedAsync; } @@ -139,6 +142,7 @@ public void SetInputPin(ISoundProvider source) public void HandleInitializationOrUnderrun(bool isUnderrun, ref int samplesNeeded) { + // TODO-me : interesting // Fill device buffer with silence but leave enough room for one frame int samplesPerFrame = (int)Math.Round(SampleRate / _getCoreVsyncRateCallback()); int silenceSamples = Math.Max(samplesNeeded - samplesPerFrame, 0); @@ -154,6 +158,7 @@ public void HandleInitializationOrUnderrun(bool isUnderrun, ref int samplesNeede public void UpdateSound(float atten, bool isSecondaryThrottlingDisabled) { + if (!Config.SoundEnabled || !IsStarted || _bufferedProvider == null || _disposed) { _bufferedProvider?.DiscardSamples(); @@ -193,6 +198,7 @@ public void UpdateSound(float atten, bool isSecondaryThrottlingDisabled) int outputThresholdMs = 20; while (sampleCount > samplesNeeded) { + // TODO-me : interesting if (samplesNeeded >= outputThresholdMs * samplesPerMs) { // If we were given a large enough number of samples (e.g. larger than the device's diff --git a/src/BizHawk.Client.EmuHawk/config/SoundConfig.Designer.cs b/src/BizHawk.Client.EmuHawk/config/SoundConfig.Designer.cs index fc60c8a5a59..195033996b5 100644 --- a/src/BizHawk.Client.EmuHawk/config/SoundConfig.Designer.cs +++ b/src/BizHawk.Client.EmuHawk/config/SoundConfig.Designer.cs @@ -28,330 +28,369 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - this.Cancel = new System.Windows.Forms.Button(); - this.OK = new System.Windows.Forms.Button(); - this.cbEnableNormal = new System.Windows.Forms.CheckBox(); - this.grpSoundVol = new System.Windows.Forms.GroupBox(); - this.nudRWFF = new System.Windows.Forms.NumericUpDown(); - this.cbEnableRWFF = new System.Windows.Forms.CheckBox(); - this.tbRWFF = new System.Windows.Forms.TrackBar(); - this.label2 = new BizHawk.WinForms.Controls.LocLabelEx(); - this.label1 = new BizHawk.WinForms.Controls.LocLabelEx(); - this.tbNormal = new System.Windows.Forms.TrackBar(); - this.nudNormal = new System.Windows.Forms.NumericUpDown(); - this.listBoxSoundDevices = new System.Windows.Forms.ListBox(); - this.SoundDeviceLabel = new BizHawk.WinForms.Controls.LocLabelEx(); - this.BufferSizeLabel = new BizHawk.WinForms.Controls.LocLabelEx(); - this.BufferSizeNumeric = new System.Windows.Forms.NumericUpDown(); - this.BufferSizeUnitsLabel = new BizHawk.WinForms.Controls.LocLabelEx(); - this.grpOutputMethod = new System.Windows.Forms.GroupBox(); - this.rbOutputMethodOpenAL = new System.Windows.Forms.RadioButton(); - this.rbOutputMethodXAudio2 = new System.Windows.Forms.RadioButton(); - this.rbOutputMethodDirectSound = new System.Windows.Forms.RadioButton(); - this.cbMuteFrameAdvance = new System.Windows.Forms.CheckBox(); - this.cbEnableMaster = new System.Windows.Forms.CheckBox(); - this.label3 = new BizHawk.WinForms.Controls.LocLabelEx(); - this.grpSoundVol.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.nudRWFF)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.tbRWFF)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.tbNormal)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.nudNormal)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.BufferSizeNumeric)).BeginInit(); - this.grpOutputMethod.SuspendLayout(); - this.SuspendLayout(); - // - // Cancel - // - this.Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.Cancel.Location = new System.Drawing.Point(317, 244); - this.Cancel.Name = "Cancel"; - this.Cancel.Size = new System.Drawing.Size(75, 23); - this.Cancel.TabIndex = 1; - this.Cancel.Text = "&Cancel"; - this.Cancel.UseVisualStyleBackColor = true; - this.Cancel.Click += new System.EventHandler(this.Cancel_Click); - // - // OK - // - this.OK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.OK.Location = new System.Drawing.Point(236, 244); - this.OK.Name = "OK"; - this.OK.Size = new System.Drawing.Size(75, 23); - this.OK.TabIndex = 0; - this.OK.Text = "&OK"; - this.OK.UseVisualStyleBackColor = true; - this.OK.Click += new System.EventHandler(this.Ok_Click); - // - // cbEnableNormal - // - this.cbEnableNormal.AutoSize = true; - this.cbEnableNormal.Location = new System.Drawing.Point(6, 20); - this.cbEnableNormal.Name = "cbEnableNormal"; - this.cbEnableNormal.Size = new System.Drawing.Size(48, 17); - this.cbEnableNormal.TabIndex = 0; - this.cbEnableNormal.Text = "Ena."; - this.cbEnableNormal.UseVisualStyleBackColor = true; - this.cbEnableNormal.CheckedChanged += new System.EventHandler(this.UpdateSoundDialog); - // - // grpSoundVol - // - this.grpSoundVol.Controls.Add(this.nudRWFF); - this.grpSoundVol.Controls.Add(this.cbEnableRWFF); - this.grpSoundVol.Controls.Add(this.tbRWFF); - this.grpSoundVol.Controls.Add(this.label2); - this.grpSoundVol.Controls.Add(this.label1); - this.grpSoundVol.Controls.Add(this.tbNormal); - this.grpSoundVol.Controls.Add(this.nudNormal); - this.grpSoundVol.Controls.Add(this.cbEnableNormal); - this.grpSoundVol.Location = new System.Drawing.Point(12, 12); - this.grpSoundVol.Name = "grpSoundVol"; - this.grpSoundVol.Size = new System.Drawing.Size(117, 255); - this.grpSoundVol.TabIndex = 2; - this.grpSoundVol.TabStop = false; - this.grpSoundVol.Text = "Volume"; - // - // nudRWFF - // - this.nudRWFF.Location = new System.Drawing.Point(58, 223); - this.nudRWFF.Name = "nudRWFF"; - this.nudRWFF.Size = new System.Drawing.Size(45, 20); - this.nudRWFF.TabIndex = 7; - this.nudRWFF.Value = new decimal(new int[] { + this.Cancel = new System.Windows.Forms.Button(); + this.OK = new System.Windows.Forms.Button(); + this.cbEnableNormal = new System.Windows.Forms.CheckBox(); + this.grpSoundVol = new System.Windows.Forms.GroupBox(); + this.nudRWFF = new System.Windows.Forms.NumericUpDown(); + this.cbEnableRWFF = new System.Windows.Forms.CheckBox(); + this.tbRWFF = new System.Windows.Forms.TrackBar(); + this.label2 = new BizHawk.WinForms.Controls.LocLabelEx(); + this.label1 = new BizHawk.WinForms.Controls.LocLabelEx(); + this.tbNormal = new System.Windows.Forms.TrackBar(); + this.nudNormal = new System.Windows.Forms.NumericUpDown(); + this.listBoxSoundDevices = new System.Windows.Forms.ListBox(); + this.SoundDeviceLabel = new BizHawk.WinForms.Controls.LocLabelEx(); + this.BufferSizeLabel = new BizHawk.WinForms.Controls.LocLabelEx(); + this.BufferSizeNumeric = new System.Windows.Forms.NumericUpDown(); + this.BufferSizeUnitsLabel = new BizHawk.WinForms.Controls.LocLabelEx(); + this.grpOutputMethod = new System.Windows.Forms.GroupBox(); + this.rbOutputMethodOpenAL = new System.Windows.Forms.RadioButton(); + this.rbOutputMethodXAudio2 = new System.Windows.Forms.RadioButton(); + this.rbOutputMethodDirectSound = new System.Windows.Forms.RadioButton(); + this.cbMuteFrameAdvance = new System.Windows.Forms.CheckBox(); + this.cbEnableMaster = new System.Windows.Forms.CheckBox(); + this.label3 = new BizHawk.WinForms.Controls.LocLabelEx(); + this.MuteInBG = new System.Windows.Forms.CheckBox(); + this.grpSoundVol.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.nudRWFF)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.tbRWFF)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.tbNormal)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.nudNormal)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.BufferSizeNumeric)).BeginInit(); + this.grpOutputMethod.SuspendLayout(); + this.SuspendLayout(); + // + // Cancel + // + this.Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.Cancel.Location = new System.Drawing.Point(864, 701); + this.Cancel.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7); + this.Cancel.Name = "Cancel"; + this.Cancel.Size = new System.Drawing.Size(200, 55); + this.Cancel.TabIndex = 1; + this.Cancel.Text = "&Cancel"; + this.Cancel.UseVisualStyleBackColor = true; + this.Cancel.Click += new System.EventHandler(this.Cancel_Click); + // + // OK + // + this.OK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.OK.Location = new System.Drawing.Point(648, 701); + this.OK.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7); + this.OK.Name = "OK"; + this.OK.Size = new System.Drawing.Size(200, 55); + this.OK.TabIndex = 0; + this.OK.Text = "&OK"; + this.OK.UseVisualStyleBackColor = true; + this.OK.Click += new System.EventHandler(this.Ok_Click); + // + // cbEnableNormal + // + this.cbEnableNormal.AutoSize = true; + this.cbEnableNormal.Location = new System.Drawing.Point(16, 48); + this.cbEnableNormal.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7); + this.cbEnableNormal.Name = "cbEnableNormal"; + this.cbEnableNormal.Size = new System.Drawing.Size(111, 36); + this.cbEnableNormal.TabIndex = 0; + this.cbEnableNormal.Text = "Ena."; + this.cbEnableNormal.UseVisualStyleBackColor = true; + this.cbEnableNormal.CheckedChanged += new System.EventHandler(this.UpdateSoundDialog); + // + // grpSoundVol + // + this.grpSoundVol.Controls.Add(this.nudRWFF); + this.grpSoundVol.Controls.Add(this.cbEnableRWFF); + this.grpSoundVol.Controls.Add(this.tbRWFF); + this.grpSoundVol.Controls.Add(this.label2); + this.grpSoundVol.Controls.Add(this.label1); + this.grpSoundVol.Controls.Add(this.tbNormal); + this.grpSoundVol.Controls.Add(this.nudNormal); + this.grpSoundVol.Controls.Add(this.cbEnableNormal); + this.grpSoundVol.Location = new System.Drawing.Point(32, 29); + this.grpSoundVol.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7); + this.grpSoundVol.Name = "grpSoundVol"; + this.grpSoundVol.Padding = new System.Windows.Forms.Padding(8, 7, 8, 7); + this.grpSoundVol.Size = new System.Drawing.Size(312, 608); + this.grpSoundVol.TabIndex = 2; + this.grpSoundVol.TabStop = false; + this.grpSoundVol.Text = "Volume"; + // + // nudRWFF + // + this.nudRWFF.Location = new System.Drawing.Point(155, 532); + this.nudRWFF.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7); + this.nudRWFF.Name = "nudRWFF"; + this.nudRWFF.Size = new System.Drawing.Size(120, 38); + this.nudRWFF.TabIndex = 7; + this.nudRWFF.Value = new decimal(new int[] { 100, 0, 0, 0}); - this.nudRWFF.ValueChanged += new System.EventHandler(this.nudRWFF_ValueChanged); - // - // cbEnableRWFF - // - this.cbEnableRWFF.AutoSize = true; - this.cbEnableRWFF.Location = new System.Drawing.Point(58, 20); - this.cbEnableRWFF.Name = "cbEnableRWFF"; - this.cbEnableRWFF.Size = new System.Drawing.Size(48, 17); - this.cbEnableRWFF.TabIndex = 4; - this.cbEnableRWFF.Text = "Ena."; - this.cbEnableRWFF.UseVisualStyleBackColor = true; - // - // tbRWFF - // - this.tbRWFF.LargeChange = 10; - this.tbRWFF.Location = new System.Drawing.Point(64, 53); - this.tbRWFF.Maximum = 100; - this.tbRWFF.Name = "tbRWFF"; - this.tbRWFF.Orientation = System.Windows.Forms.Orientation.Vertical; - this.tbRWFF.Size = new System.Drawing.Size(42, 164); - this.tbRWFF.TabIndex = 6; - this.tbRWFF.TickFrequency = 10; - this.tbRWFF.Scroll += new System.EventHandler(this.TbRwff_Scroll); - // - // label2 - // - this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.label2.Location = new System.Drawing.Point(56, 42); - this.label2.Name = "label2"; - this.label2.Text = "RW && FF"; - // - // label1 - // - this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.label1.Location = new System.Drawing.Point(6, 42); - this.label1.Name = "label1"; - this.label1.Text = "Normal"; - // - // tbNormal - // - this.tbNormal.LargeChange = 10; - this.tbNormal.Location = new System.Drawing.Point(8, 53); - this.tbNormal.Maximum = 100; - this.tbNormal.Name = "tbNormal"; - this.tbNormal.Orientation = System.Windows.Forms.Orientation.Vertical; - this.tbNormal.Size = new System.Drawing.Size(42, 164); - this.tbNormal.TabIndex = 2; - this.tbNormal.TickFrequency = 10; - this.tbNormal.Scroll += new System.EventHandler(this.TrackBar1_Scroll); - // - // nudNormal - // - this.nudNormal.Location = new System.Drawing.Point(5, 223); - this.nudNormal.Name = "nudNormal"; - this.nudNormal.Size = new System.Drawing.Size(45, 20); - this.nudNormal.TabIndex = 3; - this.nudNormal.Value = new decimal(new int[] { + this.nudRWFF.ValueChanged += new System.EventHandler(this.nudRWFF_ValueChanged); + // + // cbEnableRWFF + // + this.cbEnableRWFF.AutoSize = true; + this.cbEnableRWFF.Location = new System.Drawing.Point(155, 48); + this.cbEnableRWFF.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7); + this.cbEnableRWFF.Name = "cbEnableRWFF"; + this.cbEnableRWFF.Size = new System.Drawing.Size(111, 36); + this.cbEnableRWFF.TabIndex = 4; + this.cbEnableRWFF.Text = "Ena."; + this.cbEnableRWFF.UseVisualStyleBackColor = true; + // + // tbRWFF + // + this.tbRWFF.LargeChange = 10; + this.tbRWFF.Location = new System.Drawing.Point(171, 126); + this.tbRWFF.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7); + this.tbRWFF.Maximum = 100; + this.tbRWFF.Name = "tbRWFF"; + this.tbRWFF.Orientation = System.Windows.Forms.Orientation.Vertical; + this.tbRWFF.Size = new System.Drawing.Size(114, 391); + this.tbRWFF.TabIndex = 6; + this.tbRWFF.TickFrequency = 10; + this.tbRWFF.Scroll += new System.EventHandler(this.TbRwff_Scroll); + // + // label2 + // + this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.label2.Location = new System.Drawing.Point(149, 100); + this.label2.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0); + this.label2.Name = "label2"; + this.label2.Text = "RW && FF"; + // + // label1 + // + this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.label1.Location = new System.Drawing.Point(16, 100); + this.label1.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0); + this.label1.Name = "label1"; + this.label1.Text = "Normal"; + // + // tbNormal + // + this.tbNormal.LargeChange = 10; + this.tbNormal.Location = new System.Drawing.Point(21, 126); + this.tbNormal.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7); + this.tbNormal.Maximum = 100; + this.tbNormal.Name = "tbNormal"; + this.tbNormal.Orientation = System.Windows.Forms.Orientation.Vertical; + this.tbNormal.Size = new System.Drawing.Size(114, 391); + this.tbNormal.TabIndex = 2; + this.tbNormal.TickFrequency = 10; + this.tbNormal.Scroll += new System.EventHandler(this.TrackBar1_Scroll); + // + // nudNormal + // + this.nudNormal.Location = new System.Drawing.Point(13, 532); + this.nudNormal.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7); + this.nudNormal.Name = "nudNormal"; + this.nudNormal.Size = new System.Drawing.Size(120, 38); + this.nudNormal.TabIndex = 3; + this.nudNormal.Value = new decimal(new int[] { 100, 0, 0, 0}); - this.nudNormal.ValueChanged += new System.EventHandler(this.SoundVolNumeric_ValueChanged); - // - // listBoxSoundDevices - // - this.listBoxSoundDevices.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + this.nudNormal.ValueChanged += new System.EventHandler(this.SoundVolNumeric_ValueChanged); + // + // listBoxSoundDevices + // + this.listBoxSoundDevices.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.listBoxSoundDevices.FormattingEnabled = true; - this.listBoxSoundDevices.Location = new System.Drawing.Point(138, 110); - this.listBoxSoundDevices.Name = "listBoxSoundDevices"; - this.listBoxSoundDevices.Size = new System.Drawing.Size(254, 95); - this.listBoxSoundDevices.TabIndex = 8; - // - // SoundDeviceLabel - // - this.SoundDeviceLabel.Location = new System.Drawing.Point(135, 89); - this.SoundDeviceLabel.Name = "SoundDeviceLabel"; - this.SoundDeviceLabel.Text = "Sound Device:"; - // - // BufferSizeLabel - // - this.BufferSizeLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.BufferSizeLabel.Location = new System.Drawing.Point(135, 210); - this.BufferSizeLabel.Name = "BufferSizeLabel"; - this.BufferSizeLabel.Text = "Buffer Size:"; - // - // BufferSizeNumeric - // - this.BufferSizeNumeric.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.BufferSizeNumeric.Location = new System.Drawing.Point(202, 208); - this.BufferSizeNumeric.Maximum = new decimal(new int[] { + this.listBoxSoundDevices.FormattingEnabled = true; + this.listBoxSoundDevices.ItemHeight = 31; + this.listBoxSoundDevices.Location = new System.Drawing.Point(371, 323); + this.listBoxSoundDevices.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7); + this.listBoxSoundDevices.Name = "listBoxSoundDevices"; + this.listBoxSoundDevices.Size = new System.Drawing.Size(675, 314); + this.listBoxSoundDevices.TabIndex = 8; + // + // SoundDeviceLabel + // + this.SoundDeviceLabel.Location = new System.Drawing.Point(365, 284); + this.SoundDeviceLabel.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0); + this.SoundDeviceLabel.Name = "SoundDeviceLabel"; + this.SoundDeviceLabel.Text = "Sound Device:"; + // + // BufferSizeLabel + // + this.BufferSizeLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.BufferSizeLabel.Location = new System.Drawing.Point(365, 644); + this.BufferSizeLabel.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0); + this.BufferSizeLabel.Name = "BufferSizeLabel"; + this.BufferSizeLabel.Text = "Buffer Size:"; + // + // BufferSizeNumeric + // + this.BufferSizeNumeric.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.BufferSizeNumeric.Location = new System.Drawing.Point(535, 642); + this.BufferSizeNumeric.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7); + this.BufferSizeNumeric.Maximum = new decimal(new int[] { 250, 0, 0, 0}); - this.BufferSizeNumeric.Minimum = new decimal(new int[] { + this.BufferSizeNumeric.Minimum = new decimal(new int[] { 30, 0, 0, 0}); - this.BufferSizeNumeric.Name = "BufferSizeNumeric"; - this.BufferSizeNumeric.Size = new System.Drawing.Size(59, 20); - this.BufferSizeNumeric.TabIndex = 10; - this.BufferSizeNumeric.Value = new decimal(new int[] { + this.BufferSizeNumeric.Name = "BufferSizeNumeric"; + this.BufferSizeNumeric.Size = new System.Drawing.Size(157, 38); + this.BufferSizeNumeric.TabIndex = 10; + this.BufferSizeNumeric.Value = new decimal(new int[] { 100, 0, 0, 0}); - // - // BufferSizeUnitsLabel - // - this.BufferSizeUnitsLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.BufferSizeUnitsLabel.Location = new System.Drawing.Point(267, 210); - this.BufferSizeUnitsLabel.Name = "BufferSizeUnitsLabel"; - this.BufferSizeUnitsLabel.Text = "milliseconds"; - // - // grpOutputMethod - // - this.grpOutputMethod.Controls.Add(this.rbOutputMethodOpenAL); - this.grpOutputMethod.Controls.Add(this.rbOutputMethodXAudio2); - this.grpOutputMethod.Controls.Add(this.rbOutputMethodDirectSound); - this.grpOutputMethod.Location = new System.Drawing.Point(292, 12); - this.grpOutputMethod.Name = "grpOutputMethod"; - this.grpOutputMethod.Size = new System.Drawing.Size(100, 90); - this.grpOutputMethod.TabIndex = 12; - this.grpOutputMethod.TabStop = false; - this.grpOutputMethod.Text = "Output Method"; - // - // rbOutputMethodOpenAL - // - this.rbOutputMethodOpenAL.AutoSize = true; - this.rbOutputMethodOpenAL.Location = new System.Drawing.Point(6, 65); - this.rbOutputMethodOpenAL.Name = "rbOutputMethodOpenAL"; - this.rbOutputMethodOpenAL.Size = new System.Drawing.Size(64, 17); - this.rbOutputMethodOpenAL.TabIndex = 2; - this.rbOutputMethodOpenAL.TabStop = true; - this.rbOutputMethodOpenAL.Text = "OpenAL"; - this.rbOutputMethodOpenAL.UseVisualStyleBackColor = true; - this.rbOutputMethodOpenAL.CheckedChanged += new System.EventHandler(this.OutputMethodRadioButtons_CheckedChanged); - // - // rbOutputMethodXAudio2 - // - this.rbOutputMethodXAudio2.AutoSize = true; - this.rbOutputMethodXAudio2.Location = new System.Drawing.Point(6, 42); - this.rbOutputMethodXAudio2.Name = "rbOutputMethodXAudio2"; - this.rbOutputMethodXAudio2.Size = new System.Drawing.Size(65, 17); - this.rbOutputMethodXAudio2.TabIndex = 1; - this.rbOutputMethodXAudio2.TabStop = true; - this.rbOutputMethodXAudio2.Text = "XAudio2"; - this.rbOutputMethodXAudio2.UseVisualStyleBackColor = true; - this.rbOutputMethodXAudio2.CheckedChanged += new System.EventHandler(this.OutputMethodRadioButtons_CheckedChanged); - // - // rbOutputMethodDirectSound - // - this.rbOutputMethodDirectSound.AutoSize = true; - this.rbOutputMethodDirectSound.Location = new System.Drawing.Point(6, 19); - this.rbOutputMethodDirectSound.Name = "rbOutputMethodDirectSound"; - this.rbOutputMethodDirectSound.Size = new System.Drawing.Size(84, 17); - this.rbOutputMethodDirectSound.TabIndex = 0; - this.rbOutputMethodDirectSound.TabStop = true; - this.rbOutputMethodDirectSound.Text = "DirectSound"; - this.rbOutputMethodDirectSound.UseVisualStyleBackColor = true; - this.rbOutputMethodDirectSound.CheckedChanged += new System.EventHandler(this.OutputMethodRadioButtons_CheckedChanged); - // - // cbMuteFrameAdvance - // - this.cbMuteFrameAdvance.AutoSize = true; - this.cbMuteFrameAdvance.Location = new System.Drawing.Point(139, 68); - this.cbMuteFrameAdvance.Name = "cbMuteFrameAdvance"; - this.cbMuteFrameAdvance.Size = new System.Drawing.Size(128, 17); - this.cbMuteFrameAdvance.TabIndex = 6; - this.cbMuteFrameAdvance.Text = "Mute Frame Advance"; - this.cbMuteFrameAdvance.UseVisualStyleBackColor = true; - // - // cbEnableMaster - // - this.cbEnableMaster.AutoSize = true; - this.cbEnableMaster.Location = new System.Drawing.Point(139, 16); - this.cbEnableMaster.Name = "cbEnableMaster"; - this.cbEnableMaster.Size = new System.Drawing.Size(128, 17); - this.cbEnableMaster.TabIndex = 4; - this.cbEnableMaster.Text = "Sound Master Enable"; - this.cbEnableMaster.UseVisualStyleBackColor = true; - this.cbEnableMaster.CheckedChanged += new System.EventHandler(this.UpdateSoundDialog); - // - // label3 - // - this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.label3.Location = new System.Drawing.Point(161, 35); - this.label3.Name = "label3"; - this.label3.Text = "Controls whether cores\neven generate audio."; - // - // SoundConfig - // - this.AcceptButton = this.OK; - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.CancelButton = this.Cancel; - this.ClientSize = new System.Drawing.Size(404, 279); - this.Controls.Add(this.label3); - this.Controls.Add(this.cbEnableMaster); - this.Controls.Add(this.cbMuteFrameAdvance); - this.Controls.Add(this.grpOutputMethod); - this.Controls.Add(this.BufferSizeUnitsLabel); - this.Controls.Add(this.BufferSizeNumeric); - this.Controls.Add(this.BufferSizeLabel); - this.Controls.Add(this.SoundDeviceLabel); - this.Controls.Add(this.listBoxSoundDevices); - this.Controls.Add(this.grpSoundVol); - this.Controls.Add(this.OK); - this.Controls.Add(this.Cancel); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.MinimumSize = new System.Drawing.Size(279, 259); - this.Name = "SoundConfig"; - this.ShowIcon = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "Sound Configuration"; - this.Load += new System.EventHandler(this.SoundConfig_Load); - this.grpSoundVol.ResumeLayout(false); - this.grpSoundVol.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.nudRWFF)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.tbRWFF)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.tbNormal)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.nudNormal)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.BufferSizeNumeric)).EndInit(); - this.grpOutputMethod.ResumeLayout(false); - this.grpOutputMethod.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); + // + // BufferSizeUnitsLabel + // + this.BufferSizeUnitsLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.BufferSizeUnitsLabel.Location = new System.Drawing.Point(697, 648); + this.BufferSizeUnitsLabel.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0); + this.BufferSizeUnitsLabel.Name = "BufferSizeUnitsLabel"; + this.BufferSizeUnitsLabel.Text = "milliseconds"; + // + // grpOutputMethod + // + this.grpOutputMethod.Controls.Add(this.rbOutputMethodOpenAL); + this.grpOutputMethod.Controls.Add(this.rbOutputMethodXAudio2); + this.grpOutputMethod.Controls.Add(this.rbOutputMethodDirectSound); + this.grpOutputMethod.Location = new System.Drawing.Point(779, 29); + this.grpOutputMethod.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7); + this.grpOutputMethod.Name = "grpOutputMethod"; + this.grpOutputMethod.Padding = new System.Windows.Forms.Padding(8, 7, 8, 7); + this.grpOutputMethod.Size = new System.Drawing.Size(267, 215); + this.grpOutputMethod.TabIndex = 12; + this.grpOutputMethod.TabStop = false; + this.grpOutputMethod.Text = "Output Method"; + // + // rbOutputMethodOpenAL + // + this.rbOutputMethodOpenAL.AutoSize = true; + this.rbOutputMethodOpenAL.Location = new System.Drawing.Point(16, 155); + this.rbOutputMethodOpenAL.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7); + this.rbOutputMethodOpenAL.Name = "rbOutputMethodOpenAL"; + this.rbOutputMethodOpenAL.Size = new System.Drawing.Size(156, 36); + this.rbOutputMethodOpenAL.TabIndex = 2; + this.rbOutputMethodOpenAL.TabStop = true; + this.rbOutputMethodOpenAL.Text = "OpenAL"; + this.rbOutputMethodOpenAL.UseVisualStyleBackColor = true; + this.rbOutputMethodOpenAL.CheckedChanged += new System.EventHandler(this.OutputMethodRadioButtons_CheckedChanged); + // + // rbOutputMethodXAudio2 + // + this.rbOutputMethodXAudio2.AutoSize = true; + this.rbOutputMethodXAudio2.Location = new System.Drawing.Point(16, 100); + this.rbOutputMethodXAudio2.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7); + this.rbOutputMethodXAudio2.Name = "rbOutputMethodXAudio2"; + this.rbOutputMethodXAudio2.Size = new System.Drawing.Size(160, 36); + this.rbOutputMethodXAudio2.TabIndex = 1; + this.rbOutputMethodXAudio2.TabStop = true; + this.rbOutputMethodXAudio2.Text = "XAudio2"; + this.rbOutputMethodXAudio2.UseVisualStyleBackColor = true; + this.rbOutputMethodXAudio2.CheckedChanged += new System.EventHandler(this.OutputMethodRadioButtons_CheckedChanged); + // + // rbOutputMethodDirectSound + // + this.rbOutputMethodDirectSound.AutoSize = true; + this.rbOutputMethodDirectSound.Location = new System.Drawing.Point(16, 45); + this.rbOutputMethodDirectSound.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7); + this.rbOutputMethodDirectSound.Name = "rbOutputMethodDirectSound"; + this.rbOutputMethodDirectSound.Size = new System.Drawing.Size(208, 36); + this.rbOutputMethodDirectSound.TabIndex = 0; + this.rbOutputMethodDirectSound.TabStop = true; + this.rbOutputMethodDirectSound.Text = "DirectSound"; + this.rbOutputMethodDirectSound.UseVisualStyleBackColor = true; + this.rbOutputMethodDirectSound.CheckedChanged += new System.EventHandler(this.OutputMethodRadioButtons_CheckedChanged); + // + // cbMuteFrameAdvance + // + this.cbMuteFrameAdvance.AutoSize = true; + this.cbMuteFrameAdvance.Location = new System.Drawing.Point(371, 155); + this.cbMuteFrameAdvance.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7); + this.cbMuteFrameAdvance.Name = "cbMuteFrameAdvance"; + this.cbMuteFrameAdvance.Size = new System.Drawing.Size(321, 36); + this.cbMuteFrameAdvance.TabIndex = 6; + this.cbMuteFrameAdvance.Text = "Mute Frame Advance"; + this.cbMuteFrameAdvance.UseVisualStyleBackColor = true; + // + // cbEnableMaster + // + this.cbEnableMaster.AutoSize = true; + this.cbEnableMaster.Location = new System.Drawing.Point(371, 38); + this.cbEnableMaster.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7); + this.cbEnableMaster.Name = "cbEnableMaster"; + this.cbEnableMaster.Size = new System.Drawing.Size(325, 36); + this.cbEnableMaster.TabIndex = 4; + this.cbEnableMaster.Text = "Sound Master Enable"; + this.cbEnableMaster.UseVisualStyleBackColor = true; + this.cbEnableMaster.CheckedChanged += new System.EventHandler(this.UpdateSoundDialog); + // + // label3 + // + this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.label3.Location = new System.Drawing.Point(401, 81); + this.label3.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0); + this.label3.Name = "label3"; + this.label3.Text = "Controls whether cores\neven generate audio."; + // + // MuteInBG + // + this.MuteInBG.AutoSize = true; + this.MuteInBG.Location = new System.Drawing.Point(371, 208); + this.MuteInBG.Name = "MuteInBG"; + this.MuteInBG.Size = new System.Drawing.Size(301, 36); + this.MuteInBG.TabIndex = 16; + this.MuteInBG.Text = "Mute in background"; + this.MuteInBG.UseVisualStyleBackColor = true; + // + // SoundConfig + // + this.AcceptButton = this.OK; + this.AutoScaleDimensions = new System.Drawing.SizeF(16F, 31F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.Cancel; + this.ClientSize = new System.Drawing.Size(1081, 772); + this.Controls.Add(this.MuteInBG); + this.Controls.Add(this.label3); + this.Controls.Add(this.cbEnableMaster); + this.Controls.Add(this.cbMuteFrameAdvance); + this.Controls.Add(this.grpOutputMethod); + this.Controls.Add(this.BufferSizeUnitsLabel); + this.Controls.Add(this.BufferSizeNumeric); + this.Controls.Add(this.BufferSizeLabel); + this.Controls.Add(this.SoundDeviceLabel); + this.Controls.Add(this.listBoxSoundDevices); + this.Controls.Add(this.grpSoundVol); + this.Controls.Add(this.OK); + this.Controls.Add(this.Cancel); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7); + this.MinimumSize = new System.Drawing.Size(691, 496); + this.Name = "SoundConfig"; + this.ShowIcon = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Sound Configuration"; + this.Load += new System.EventHandler(this.SoundConfig_Load); + this.grpSoundVol.ResumeLayout(false); + this.grpSoundVol.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.nudRWFF)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.tbRWFF)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.tbNormal)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.nudNormal)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.BufferSizeNumeric)).EndInit(); + this.grpOutputMethod.ResumeLayout(false); + this.grpOutputMethod.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); } @@ -380,5 +419,6 @@ private void InitializeComponent() private System.Windows.Forms.CheckBox cbMuteFrameAdvance; private System.Windows.Forms.CheckBox cbEnableMaster; private BizHawk.WinForms.Controls.LocLabelEx label3; + private System.Windows.Forms.CheckBox MuteInBG; } } \ No newline at end of file diff --git a/src/BizHawk.Client.EmuHawk/config/SoundConfig.cs b/src/BizHawk.Client.EmuHawk/config/SoundConfig.cs index 093a3d94c78..944337ebcea 100644 --- a/src/BizHawk.Client.EmuHawk/config/SoundConfig.cs +++ b/src/BizHawk.Client.EmuHawk/config/SoundConfig.cs @@ -22,6 +22,7 @@ public SoundConfig(IDialogController dialogController, Config config, Func"; + _config.MuteInBG = MuteInBG.Checked; DialogResult = DialogResult.OK; } @@ -145,5 +148,10 @@ private void nudRWFF_ValueChanged(object sender, EventArgs e) { tbRWFF.Value = (int)nudRWFF.Value; } + + public bool GetMuteInBackgroundChecked() { + return MuteInBG.Checked; + } + } } From c7cecc9368f20130064921db0b6401a1d171d646 Mon Sep 17 00:00:00 2001 From: FredTheHunter Date: Fri, 8 Mar 2024 15:02:34 -0500 Subject: [PATCH 2/9] feat : Made it so the option to mute in background also mutes the game when it is unfocused --- src/BizHawk.Client.EmuHawk/MainForm.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index f9725002b38..ace9c6f01b7 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -3301,8 +3301,9 @@ private void StepRunLoop_Core(bool force = false) // Tools will want to be updated after rewind (load state), but we only need to manually do this if we did not frame advance. UpdateToolsAfter(); } + if(Config.MuteInBG) { - if(WindowState == FormWindowState.Minimized) { + if(WindowState == FormWindowState.Minimized || Form.ActiveForm == null) { Sound.StopSound(); } else { From 1a0934f58eb0cd4eca695bb0f9fb71ac06c3a347 Mon Sep 17 00:00:00 2001 From: FredTheHunter Date: Sat, 9 Mar 2024 14:52:27 -0500 Subject: [PATCH 3/9] added a mute on lag option with an fps threshold that can be changed in sound settings --- .../Sound/Utilities/BufferedAsync.cs | 1 - src/BizHawk.Client.Common/config/Config.cs | 4 ++ src/BizHawk.Client.EmuHawk/MainForm.cs | 19 +++++- src/BizHawk.Client.EmuHawk/Sound/Sound.cs | 5 -- .../config/SoundConfig.Designer.cs | 63 ++++++++++++++++--- .../config/SoundConfig.cs | 14 ++++- 6 files changed, 86 insertions(+), 20 deletions(-) diff --git a/src/BizHawk.Client.Common/Sound/Utilities/BufferedAsync.cs b/src/BizHawk.Client.Common/Sound/Utilities/BufferedAsync.cs index 0349c4c90a0..14795ab8978 100644 --- a/src/BizHawk.Client.Common/Sound/Utilities/BufferedAsync.cs +++ b/src/BizHawk.Client.Common/Sound/Utilities/BufferedAsync.cs @@ -45,7 +45,6 @@ public sealed class BufferedAsync : ISoundProvider, IBufferedSoundProvider /// public void RecalculateMagic(double framerate) { - // TODO-me : might be useful! // ceiling instead of floor here is very important (magic) SamplesInOneFrame = 2 * (int)Math.Ceiling((44100.0 / framerate)); //TargetExtraSamples = ;// complete guess diff --git a/src/BizHawk.Client.Common/config/Config.cs b/src/BizHawk.Client.Common/config/Config.cs index 8e9173f6336..d67da7d7f04 100644 --- a/src/BizHawk.Client.Common/config/Config.cs +++ b/src/BizHawk.Client.Common/config/Config.cs @@ -257,6 +257,10 @@ public void ResolveDefaults() public bool MuteInBG { get; set; } = false; + public bool MuteOnLag { get; set; } = false; + + public decimal FPSThreshold { get; set; } = 100; + // Lua public RecentFiles RecentLua { get; set; } = new RecentFiles(8); public RecentFiles RecentLuaSession { get; set; } = new RecentFiles(8); diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index ace9c6f01b7..0882148e162 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -3302,7 +3302,10 @@ private void StepRunLoop_Core(bool force = false) UpdateToolsAfter(); } - if(Config.MuteInBG) { + + // Mutes the game if EmuHawk is unfocused or minimized + // An option in the sound settings needs to be turned on for this to work. + if (Config.MuteInBG) { if(WindowState == FormWindowState.Minimized || Form.ActiveForm == null) { Sound.StopSound(); } @@ -3313,6 +3316,20 @@ private void StepRunLoop_Core(bool force = false) Sound.StartSound(); } + // Mutes the game if the current FPS reaches the threshold chosen by the user or lower + // An option in the sound settings needs to be turned on for this to work. + if(Config.MuteOnLag) { + if (_lastFps <= (double)Config.FPSThreshold) + { + Sound.StopSound(); + } + else + { + Sound.StartSound(); + } + } + + Sound.UpdateSound(atten, DisableSecondaryThrottling); } diff --git a/src/BizHawk.Client.EmuHawk/Sound/Sound.cs b/src/BizHawk.Client.EmuHawk/Sound/Sound.cs index cac25ba4f0e..02ab74b29c5 100644 --- a/src/BizHawk.Client.EmuHawk/Sound/Sound.cs +++ b/src/BizHawk.Client.EmuHawk/Sound/Sound.cs @@ -51,7 +51,6 @@ public Sound(IntPtr mainWindowHandle, Config config, Func getCoreVsyncRa { _outputDevice = config.SoundOutputMethod switch { - // TODO-me : Vérifier ici. ESoundOutputMethod.DirectSound => new DirectSoundSoundOutput(this, mainWindowHandle, config.SoundDevice), ESoundOutputMethod.XAudio2 => new XAudio2SoundOutput(this, config.SoundDevice), ESoundOutputMethod.OpenAL => new OpenALSoundOutput(this, config.SoundDevice), @@ -61,7 +60,6 @@ public Sound(IntPtr mainWindowHandle, Config config, Func getCoreVsyncRa } /// - /// TODO-me : Might be interesting /// The maximum number of milliseconds the sound output buffer can go below full before causing a noticeable sound interruption. /// public int SoundMaxBufferDeficitMs { get; set; } @@ -129,7 +127,6 @@ public void SetInputPin(ISoundProvider source) } else if (source.SyncMode == SyncSoundMode.Async) { - // TODO-me : RecalculateMagic could be interesting _bufferedAsync.RecalculateMagic(_getCoreVsyncRateCallback()); _bufferedProvider = _bufferedAsync; } @@ -142,7 +139,6 @@ public void SetInputPin(ISoundProvider source) public void HandleInitializationOrUnderrun(bool isUnderrun, ref int samplesNeeded) { - // TODO-me : interesting // Fill device buffer with silence but leave enough room for one frame int samplesPerFrame = (int)Math.Round(SampleRate / _getCoreVsyncRateCallback()); int silenceSamples = Math.Max(samplesNeeded - samplesPerFrame, 0); @@ -198,7 +194,6 @@ public void UpdateSound(float atten, bool isSecondaryThrottlingDisabled) int outputThresholdMs = 20; while (sampleCount > samplesNeeded) { - // TODO-me : interesting if (samplesNeeded >= outputThresholdMs * samplesPerMs) { // If we were given a large enough number of samples (e.g. larger than the device's diff --git a/src/BizHawk.Client.EmuHawk/config/SoundConfig.Designer.cs b/src/BizHawk.Client.EmuHawk/config/SoundConfig.Designer.cs index 195033996b5..9d02f27ea1a 100644 --- a/src/BizHawk.Client.EmuHawk/config/SoundConfig.Designer.cs +++ b/src/BizHawk.Client.EmuHawk/config/SoundConfig.Designer.cs @@ -52,6 +52,9 @@ private void InitializeComponent() this.cbEnableMaster = new System.Windows.Forms.CheckBox(); this.label3 = new BizHawk.WinForms.Controls.LocLabelEx(); this.MuteInBG = new System.Windows.Forms.CheckBox(); + this.muteOnLag = new System.Windows.Forms.CheckBox(); + this.fpsThreshold = new System.Windows.Forms.NumericUpDown(); + this.fpsThresholdLabel = new BizHawk.WinForms.Controls.LocLabelEx(); this.grpSoundVol.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.nudRWFF)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.tbRWFF)).BeginInit(); @@ -59,13 +62,14 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.nudNormal)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.BufferSizeNumeric)).BeginInit(); this.grpOutputMethod.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.fpsThreshold)).BeginInit(); this.SuspendLayout(); // // Cancel // this.Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.Cancel.Location = new System.Drawing.Point(864, 701); + this.Cancel.Location = new System.Drawing.Point(1009, 893); this.Cancel.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7); this.Cancel.Name = "Cancel"; this.Cancel.Size = new System.Drawing.Size(200, 55); @@ -77,7 +81,7 @@ private void InitializeComponent() // OK // this.OK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.OK.Location = new System.Drawing.Point(648, 701); + this.OK.Location = new System.Drawing.Point(793, 893); this.OK.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7); this.OK.Name = "OK"; this.OK.Size = new System.Drawing.Size(200, 55); @@ -205,15 +209,15 @@ private void InitializeComponent() | System.Windows.Forms.AnchorStyles.Right))); this.listBoxSoundDevices.FormattingEnabled = true; this.listBoxSoundDevices.ItemHeight = 31; - this.listBoxSoundDevices.Location = new System.Drawing.Point(371, 323); + this.listBoxSoundDevices.Location = new System.Drawing.Point(371, 354); this.listBoxSoundDevices.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7); this.listBoxSoundDevices.Name = "listBoxSoundDevices"; - this.listBoxSoundDevices.Size = new System.Drawing.Size(675, 314); + this.listBoxSoundDevices.Size = new System.Drawing.Size(820, 438); this.listBoxSoundDevices.TabIndex = 8; // // SoundDeviceLabel // - this.SoundDeviceLabel.Location = new System.Drawing.Point(365, 284); + this.SoundDeviceLabel.Location = new System.Drawing.Point(365, 315); this.SoundDeviceLabel.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0); this.SoundDeviceLabel.Name = "SoundDeviceLabel"; this.SoundDeviceLabel.Text = "Sound Device:"; @@ -221,7 +225,7 @@ private void InitializeComponent() // BufferSizeLabel // this.BufferSizeLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.BufferSizeLabel.Location = new System.Drawing.Point(365, 644); + this.BufferSizeLabel.Location = new System.Drawing.Point(365, 808); this.BufferSizeLabel.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0); this.BufferSizeLabel.Name = "BufferSizeLabel"; this.BufferSizeLabel.Text = "Buffer Size:"; @@ -229,7 +233,7 @@ private void InitializeComponent() // BufferSizeNumeric // this.BufferSizeNumeric.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.BufferSizeNumeric.Location = new System.Drawing.Point(535, 642); + this.BufferSizeNumeric.Location = new System.Drawing.Point(535, 806); this.BufferSizeNumeric.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7); this.BufferSizeNumeric.Maximum = new decimal(new int[] { 250, @@ -253,7 +257,7 @@ private void InitializeComponent() // BufferSizeUnitsLabel // this.BufferSizeUnitsLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.BufferSizeUnitsLabel.Location = new System.Drawing.Point(697, 648); + this.BufferSizeUnitsLabel.Location = new System.Drawing.Point(708, 808); this.BufferSizeUnitsLabel.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0); this.BufferSizeUnitsLabel.Name = "BufferSizeUnitsLabel"; this.BufferSizeUnitsLabel.Text = "milliseconds"; @@ -337,7 +341,7 @@ private void InitializeComponent() // label3 // this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.label3.Location = new System.Drawing.Point(401, 81); + this.label3.Location = new System.Drawing.Point(408, 77); this.label3.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0); this.label3.Name = "label3"; this.label3.Text = "Controls whether cores\neven generate audio."; @@ -352,13 +356,48 @@ private void InitializeComponent() this.MuteInBG.Text = "Mute in background"; this.MuteInBG.UseVisualStyleBackColor = true; // + // muteOnLag + // + this.muteOnLag.AutoSize = true; + this.muteOnLag.Location = new System.Drawing.Point(371, 258); + this.muteOnLag.Name = "muteOnLag"; + this.muteOnLag.Size = new System.Drawing.Size(200, 36); + this.muteOnLag.TabIndex = 21; + this.muteOnLag.Text = "Mute on lag"; + this.muteOnLag.UseVisualStyleBackColor = true; + this.muteOnLag.CheckedChanged += new System.EventHandler(this.muteOnLag_CheckedChanged); + // + // fpsThreshold + // + this.fpsThreshold.Location = new System.Drawing.Point(1071, 260); + this.fpsThreshold.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7); + this.fpsThreshold.Name = "fpsThreshold"; + this.fpsThreshold.Size = new System.Drawing.Size(120, 38); + this.fpsThreshold.TabIndex = 10; + this.fpsThreshold.Value = new decimal(new int[] { + 56, + 0, + 0, + 0}); + // + // fpsThresholdLabel + // + this.fpsThresholdLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.fpsThresholdLabel.Location = new System.Drawing.Point(648, 262); + this.fpsThresholdLabel.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0); + this.fpsThresholdLabel.Name = "fpsThresholdLabel"; + this.fpsThresholdLabel.Text = "FPS Threshold for Mute on Lag\r\n"; + // // SoundConfig // this.AcceptButton = this.OK; this.AutoScaleDimensions = new System.Drawing.SizeF(16F, 31F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.Cancel; - this.ClientSize = new System.Drawing.Size(1081, 772); + this.ClientSize = new System.Drawing.Size(1226, 964); + this.Controls.Add(this.fpsThresholdLabel); + this.Controls.Add(this.fpsThreshold); + this.Controls.Add(this.muteOnLag); this.Controls.Add(this.MuteInBG); this.Controls.Add(this.label3); this.Controls.Add(this.cbEnableMaster); @@ -389,6 +428,7 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.BufferSizeNumeric)).EndInit(); this.grpOutputMethod.ResumeLayout(false); this.grpOutputMethod.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.fpsThreshold)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -420,5 +460,8 @@ private void InitializeComponent() private System.Windows.Forms.CheckBox cbEnableMaster; private BizHawk.WinForms.Controls.LocLabelEx label3; private System.Windows.Forms.CheckBox MuteInBG; + private System.Windows.Forms.CheckBox muteOnLag; + private System.Windows.Forms.NumericUpDown fpsThreshold; + private WinForms.Controls.LocLabelEx fpsThresholdLabel; } } \ No newline at end of file diff --git a/src/BizHawk.Client.EmuHawk/config/SoundConfig.cs b/src/BizHawk.Client.EmuHawk/config/SoundConfig.cs index 944337ebcea..6dee21bc859 100644 --- a/src/BizHawk.Client.EmuHawk/config/SoundConfig.cs +++ b/src/BizHawk.Client.EmuHawk/config/SoundConfig.cs @@ -46,6 +46,8 @@ private void SoundConfig_Load(object sender, EventArgs e) tbRWFF.Value = _config.SoundVolumeRWFF; nudRWFF.Value = _config.SoundVolumeRWFF; MuteInBG.Checked = _config.MuteInBG; + muteOnLag.Checked = _config.MuteOnLag; + fpsThreshold.Value = _config.FPSThreshold; UpdateSoundDialog(); _programmaticallyChangingValue = false; @@ -79,6 +81,8 @@ private void Ok_Click(object sender, EventArgs e) _config.SoundVolumeRWFF = tbRWFF.Value; _config.SoundDevice = (string)listBoxSoundDevices.SelectedItem ?? ""; _config.MuteInBG = MuteInBG.Checked; + _config.MuteOnLag = muteOnLag.Checked; + _config.FPSThreshold = fpsThreshold.Value; DialogResult = DialogResult.OK; } @@ -149,9 +153,13 @@ private void nudRWFF_ValueChanged(object sender, EventArgs e) tbRWFF.Value = (int)nudRWFF.Value; } - public bool GetMuteInBackgroundChecked() { - return MuteInBG.Checked; + private void muteOnLag_CheckedChanged(object sender, EventArgs e) + { + if(muteOnLag.Checked) { + fpsThreshold.Enabled = true; + } else { + fpsThreshold.Enabled = false; + } } - } } From 462fc605cef0ed55b312c5b733cb3d63b1092775 Mon Sep 17 00:00:00 2001 From: FredTheHunter Date: Sat, 9 Mar 2024 15:13:39 -0500 Subject: [PATCH 4/9] fixed a test that I broke because of a type in configs. Also fixed default values for the fps threshold --- src/BizHawk.Client.Common/config/Config.cs | 2 +- .../config/SoundConfig.Designer.cs | 186 +++++++++--------- .../config/SoundConfig.cs | 19 +- 3 files changed, 104 insertions(+), 103 deletions(-) diff --git a/src/BizHawk.Client.Common/config/Config.cs b/src/BizHawk.Client.Common/config/Config.cs index d67da7d7f04..bee8c51bf85 100644 --- a/src/BizHawk.Client.Common/config/Config.cs +++ b/src/BizHawk.Client.Common/config/Config.cs @@ -259,7 +259,7 @@ public void ResolveDefaults() public bool MuteOnLag { get; set; } = false; - public decimal FPSThreshold { get; set; } = 100; + public int FPSThreshold { get; set; } = 56; // Lua public RecentFiles RecentLua { get; set; } = new RecentFiles(8); diff --git a/src/BizHawk.Client.EmuHawk/config/SoundConfig.Designer.cs b/src/BizHawk.Client.EmuHawk/config/SoundConfig.Designer.cs index 9d02f27ea1a..6ebcf0489c1 100644 --- a/src/BizHawk.Client.EmuHawk/config/SoundConfig.Designer.cs +++ b/src/BizHawk.Client.EmuHawk/config/SoundConfig.Designer.cs @@ -35,26 +35,26 @@ private void InitializeComponent() this.nudRWFF = new System.Windows.Forms.NumericUpDown(); this.cbEnableRWFF = new System.Windows.Forms.CheckBox(); this.tbRWFF = new System.Windows.Forms.TrackBar(); - this.label2 = new BizHawk.WinForms.Controls.LocLabelEx(); - this.label1 = new BizHawk.WinForms.Controls.LocLabelEx(); this.tbNormal = new System.Windows.Forms.TrackBar(); this.nudNormal = new System.Windows.Forms.NumericUpDown(); this.listBoxSoundDevices = new System.Windows.Forms.ListBox(); - this.SoundDeviceLabel = new BizHawk.WinForms.Controls.LocLabelEx(); - this.BufferSizeLabel = new BizHawk.WinForms.Controls.LocLabelEx(); this.BufferSizeNumeric = new System.Windows.Forms.NumericUpDown(); - this.BufferSizeUnitsLabel = new BizHawk.WinForms.Controls.LocLabelEx(); this.grpOutputMethod = new System.Windows.Forms.GroupBox(); this.rbOutputMethodOpenAL = new System.Windows.Forms.RadioButton(); this.rbOutputMethodXAudio2 = new System.Windows.Forms.RadioButton(); this.rbOutputMethodDirectSound = new System.Windows.Forms.RadioButton(); this.cbMuteFrameAdvance = new System.Windows.Forms.CheckBox(); this.cbEnableMaster = new System.Windows.Forms.CheckBox(); - this.label3 = new BizHawk.WinForms.Controls.LocLabelEx(); - this.MuteInBG = new System.Windows.Forms.CheckBox(); - this.muteOnLag = new System.Windows.Forms.CheckBox(); - this.fpsThreshold = new System.Windows.Forms.NumericUpDown(); + this.cbMuteInBG = new System.Windows.Forms.CheckBox(); + this.cbMuteOnLag = new System.Windows.Forms.CheckBox(); + this.FpsThresholdNumeric = new System.Windows.Forms.NumericUpDown(); this.fpsThresholdLabel = new BizHawk.WinForms.Controls.LocLabelEx(); + this.label3 = new BizHawk.WinForms.Controls.LocLabelEx(); + this.BufferSizeUnitsLabel = new BizHawk.WinForms.Controls.LocLabelEx(); + this.BufferSizeLabel = new BizHawk.WinForms.Controls.LocLabelEx(); + this.SoundDeviceLabel = new BizHawk.WinForms.Controls.LocLabelEx(); + this.label2 = new BizHawk.WinForms.Controls.LocLabelEx(); + this.label1 = new BizHawk.WinForms.Controls.LocLabelEx(); this.grpSoundVol.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.nudRWFF)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.tbRWFF)).BeginInit(); @@ -62,7 +62,7 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.nudNormal)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.BufferSizeNumeric)).BeginInit(); this.grpOutputMethod.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.fpsThreshold)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.FpsThresholdNumeric)).BeginInit(); this.SuspendLayout(); // // Cancel @@ -159,22 +159,6 @@ private void InitializeComponent() this.tbRWFF.TickFrequency = 10; this.tbRWFF.Scroll += new System.EventHandler(this.TbRwff_Scroll); // - // label2 - // - this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.label2.Location = new System.Drawing.Point(149, 100); - this.label2.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0); - this.label2.Name = "label2"; - this.label2.Text = "RW && FF"; - // - // label1 - // - this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.label1.Location = new System.Drawing.Point(16, 100); - this.label1.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0); - this.label1.Name = "label1"; - this.label1.Text = "Normal"; - // // tbNormal // this.tbNormal.LargeChange = 10; @@ -215,21 +199,6 @@ private void InitializeComponent() this.listBoxSoundDevices.Size = new System.Drawing.Size(820, 438); this.listBoxSoundDevices.TabIndex = 8; // - // SoundDeviceLabel - // - this.SoundDeviceLabel.Location = new System.Drawing.Point(365, 315); - this.SoundDeviceLabel.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0); - this.SoundDeviceLabel.Name = "SoundDeviceLabel"; - this.SoundDeviceLabel.Text = "Sound Device:"; - // - // BufferSizeLabel - // - this.BufferSizeLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.BufferSizeLabel.Location = new System.Drawing.Point(365, 808); - this.BufferSizeLabel.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0); - this.BufferSizeLabel.Name = "BufferSizeLabel"; - this.BufferSizeLabel.Text = "Buffer Size:"; - // // BufferSizeNumeric // this.BufferSizeNumeric.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); @@ -254,14 +223,6 @@ private void InitializeComponent() 0, 0}); // - // BufferSizeUnitsLabel - // - this.BufferSizeUnitsLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.BufferSizeUnitsLabel.Location = new System.Drawing.Point(708, 808); - this.BufferSizeUnitsLabel.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0); - this.BufferSizeUnitsLabel.Name = "BufferSizeUnitsLabel"; - this.BufferSizeUnitsLabel.Text = "milliseconds"; - // // grpOutputMethod // this.grpOutputMethod.Controls.Add(this.rbOutputMethodOpenAL); @@ -338,43 +299,35 @@ private void InitializeComponent() this.cbEnableMaster.UseVisualStyleBackColor = true; this.cbEnableMaster.CheckedChanged += new System.EventHandler(this.UpdateSoundDialog); // - // label3 - // - this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.label3.Location = new System.Drawing.Point(408, 77); - this.label3.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0); - this.label3.Name = "label3"; - this.label3.Text = "Controls whether cores\neven generate audio."; - // - // MuteInBG - // - this.MuteInBG.AutoSize = true; - this.MuteInBG.Location = new System.Drawing.Point(371, 208); - this.MuteInBG.Name = "MuteInBG"; - this.MuteInBG.Size = new System.Drawing.Size(301, 36); - this.MuteInBG.TabIndex = 16; - this.MuteInBG.Text = "Mute in background"; - this.MuteInBG.UseVisualStyleBackColor = true; - // - // muteOnLag - // - this.muteOnLag.AutoSize = true; - this.muteOnLag.Location = new System.Drawing.Point(371, 258); - this.muteOnLag.Name = "muteOnLag"; - this.muteOnLag.Size = new System.Drawing.Size(200, 36); - this.muteOnLag.TabIndex = 21; - this.muteOnLag.Text = "Mute on lag"; - this.muteOnLag.UseVisualStyleBackColor = true; - this.muteOnLag.CheckedChanged += new System.EventHandler(this.muteOnLag_CheckedChanged); - // - // fpsThreshold - // - this.fpsThreshold.Location = new System.Drawing.Point(1071, 260); - this.fpsThreshold.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7); - this.fpsThreshold.Name = "fpsThreshold"; - this.fpsThreshold.Size = new System.Drawing.Size(120, 38); - this.fpsThreshold.TabIndex = 10; - this.fpsThreshold.Value = new decimal(new int[] { + // cbMuteInBG + // + this.cbMuteInBG.AutoSize = true; + this.cbMuteInBG.Location = new System.Drawing.Point(371, 208); + this.cbMuteInBG.Name = "cbMuteInBG"; + this.cbMuteInBG.Size = new System.Drawing.Size(301, 36); + this.cbMuteInBG.TabIndex = 16; + this.cbMuteInBG.Text = "Mute in background"; + this.cbMuteInBG.UseVisualStyleBackColor = true; + // + // cbMuteOnLag + // + this.cbMuteOnLag.AutoSize = true; + this.cbMuteOnLag.Location = new System.Drawing.Point(371, 258); + this.cbMuteOnLag.Name = "cbMuteOnLag"; + this.cbMuteOnLag.Size = new System.Drawing.Size(200, 36); + this.cbMuteOnLag.TabIndex = 21; + this.cbMuteOnLag.Text = "Mute on lag"; + this.cbMuteOnLag.UseVisualStyleBackColor = true; + this.cbMuteOnLag.CheckedChanged += new System.EventHandler(this.muteOnLag_CheckedChanged); + // + // FpsThresholdNumeric + // + this.FpsThresholdNumeric.Location = new System.Drawing.Point(1071, 260); + this.FpsThresholdNumeric.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7); + this.FpsThresholdNumeric.Name = "FpsThresholdNumeric"; + this.FpsThresholdNumeric.Size = new System.Drawing.Size(120, 38); + this.FpsThresholdNumeric.TabIndex = 10; + this.FpsThresholdNumeric.Value = new decimal(new int[] { 56, 0, 0, @@ -388,6 +341,53 @@ private void InitializeComponent() this.fpsThresholdLabel.Name = "fpsThresholdLabel"; this.fpsThresholdLabel.Text = "FPS Threshold for Mute on Lag\r\n"; // + // label3 + // + this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.label3.Location = new System.Drawing.Point(408, 77); + this.label3.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0); + this.label3.Name = "label3"; + this.label3.Text = "Controls whether cores\neven generate audio."; + // + // BufferSizeUnitsLabel + // + this.BufferSizeUnitsLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.BufferSizeUnitsLabel.Location = new System.Drawing.Point(708, 808); + this.BufferSizeUnitsLabel.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0); + this.BufferSizeUnitsLabel.Name = "BufferSizeUnitsLabel"; + this.BufferSizeUnitsLabel.Text = "milliseconds"; + // + // BufferSizeLabel + // + this.BufferSizeLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.BufferSizeLabel.Location = new System.Drawing.Point(365, 808); + this.BufferSizeLabel.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0); + this.BufferSizeLabel.Name = "BufferSizeLabel"; + this.BufferSizeLabel.Text = "Buffer Size:"; + // + // SoundDeviceLabel + // + this.SoundDeviceLabel.Location = new System.Drawing.Point(365, 315); + this.SoundDeviceLabel.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0); + this.SoundDeviceLabel.Name = "SoundDeviceLabel"; + this.SoundDeviceLabel.Text = "Sound Device:"; + // + // label2 + // + this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.label2.Location = new System.Drawing.Point(149, 100); + this.label2.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0); + this.label2.Name = "label2"; + this.label2.Text = "RW && FF"; + // + // label1 + // + this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.label1.Location = new System.Drawing.Point(16, 100); + this.label1.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0); + this.label1.Name = "label1"; + this.label1.Text = "Normal"; + // // SoundConfig // this.AcceptButton = this.OK; @@ -396,9 +396,9 @@ private void InitializeComponent() this.CancelButton = this.Cancel; this.ClientSize = new System.Drawing.Size(1226, 964); this.Controls.Add(this.fpsThresholdLabel); - this.Controls.Add(this.fpsThreshold); - this.Controls.Add(this.muteOnLag); - this.Controls.Add(this.MuteInBG); + this.Controls.Add(this.FpsThresholdNumeric); + this.Controls.Add(this.cbMuteOnLag); + this.Controls.Add(this.cbMuteInBG); this.Controls.Add(this.label3); this.Controls.Add(this.cbEnableMaster); this.Controls.Add(this.cbMuteFrameAdvance); @@ -428,7 +428,7 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.BufferSizeNumeric)).EndInit(); this.grpOutputMethod.ResumeLayout(false); this.grpOutputMethod.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.fpsThreshold)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.FpsThresholdNumeric)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -459,9 +459,9 @@ private void InitializeComponent() private System.Windows.Forms.CheckBox cbMuteFrameAdvance; private System.Windows.Forms.CheckBox cbEnableMaster; private BizHawk.WinForms.Controls.LocLabelEx label3; - private System.Windows.Forms.CheckBox MuteInBG; - private System.Windows.Forms.CheckBox muteOnLag; - private System.Windows.Forms.NumericUpDown fpsThreshold; + private System.Windows.Forms.CheckBox cbMuteInBG; + private System.Windows.Forms.CheckBox cbMuteOnLag; + private System.Windows.Forms.NumericUpDown FpsThresholdNumeric; private WinForms.Controls.LocLabelEx fpsThresholdLabel; } } \ No newline at end of file diff --git a/src/BizHawk.Client.EmuHawk/config/SoundConfig.cs b/src/BizHawk.Client.EmuHawk/config/SoundConfig.cs index 6dee21bc859..413f9b0adb9 100644 --- a/src/BizHawk.Client.EmuHawk/config/SoundConfig.cs +++ b/src/BizHawk.Client.EmuHawk/config/SoundConfig.cs @@ -45,9 +45,10 @@ private void SoundConfig_Load(object sender, EventArgs e) nudNormal.Value = _config.SoundVolume; tbRWFF.Value = _config.SoundVolumeRWFF; nudRWFF.Value = _config.SoundVolumeRWFF; - MuteInBG.Checked = _config.MuteInBG; - muteOnLag.Checked = _config.MuteOnLag; - fpsThreshold.Value = _config.FPSThreshold; + cbMuteInBG.Checked = _config.MuteInBG; + cbMuteOnLag.Checked = _config.MuteOnLag; + FpsThresholdNumeric.Value = _config.FPSThreshold; + FpsThresholdNumeric.Enabled = _config.MuteOnLag; UpdateSoundDialog(); _programmaticallyChangingValue = false; @@ -80,9 +81,9 @@ private void Ok_Click(object sender, EventArgs e) _config.SoundVolume = tbNormal.Value; _config.SoundVolumeRWFF = tbRWFF.Value; _config.SoundDevice = (string)listBoxSoundDevices.SelectedItem ?? ""; - _config.MuteInBG = MuteInBG.Checked; - _config.MuteOnLag = muteOnLag.Checked; - _config.FPSThreshold = fpsThreshold.Value; + _config.MuteInBG = cbMuteInBG.Checked; + _config.MuteOnLag = cbMuteOnLag.Checked; + _config.FPSThreshold = (int)FpsThresholdNumeric.Value; DialogResult = DialogResult.OK; } @@ -155,10 +156,10 @@ private void nudRWFF_ValueChanged(object sender, EventArgs e) private void muteOnLag_CheckedChanged(object sender, EventArgs e) { - if(muteOnLag.Checked) { - fpsThreshold.Enabled = true; + if(cbMuteOnLag.Checked) { + FpsThresholdNumeric.Enabled = true; } else { - fpsThreshold.Enabled = false; + FpsThresholdNumeric.Enabled = false; } } } From ad4e372b609423c4e01bf324cfdb0eec51742679 Mon Sep 17 00:00:00 2001 From: FredTheHunter Date: Sun, 10 Mar 2024 13:10:05 -0400 Subject: [PATCH 5/9] removed useless line in gitignore and removed whitespaces that I added --- .gitignore | 2 -- src/BizHawk.Client.EmuHawk/MainForm.cs | 3 --- src/BizHawk.Client.EmuHawk/Program.cs | 6 ------ src/BizHawk.Client.EmuHawk/Sound/Sound.cs | 2 -- src/BizHawk.Client.EmuHawk/config/SoundConfig.cs | 2 -- 5 files changed, 15 deletions(-) diff --git a/.gitignore b/.gitignore index 44bb7c1f855..0922affde82 100644 --- a/.gitignore +++ b/.gitignore @@ -45,5 +45,3 @@ /packages launchSettings.json - -/Dist/copyBIOS.sh diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index 0882148e162..f07ddb38615 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -3302,7 +3302,6 @@ private void StepRunLoop_Core(bool force = false) UpdateToolsAfter(); } - // Mutes the game if EmuHawk is unfocused or minimized // An option in the sound settings needs to be turned on for this to work. if (Config.MuteInBG) { @@ -3329,9 +3328,7 @@ private void StepRunLoop_Core(bool force = false) } } - Sound.UpdateSound(atten, DisableSecondaryThrottling); - } private void CalcFramerateAndUpdateDisplay(long currentTimestamp, bool isRewinding, bool isFastForwarding) diff --git a/src/BizHawk.Client.EmuHawk/Program.cs b/src/BizHawk.Client.EmuHawk/Program.cs index 0fb5f0f97da..38a229eaf5e 100644 --- a/src/BizHawk.Client.EmuHawk/Program.cs +++ b/src/BizHawk.Client.EmuHawk/Program.cs @@ -31,14 +31,9 @@ internal static class Program static Program() { // This needs to be done before the warnings/errors show up - Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - - - - // Quickly check if the user is running this as a 32 bit process somehow // TODO: We may want to remove this sometime, EmuHawk should be able to run somewhat as 32 bit if the user really wants to // (There are no longer any hard 64 bit deps, i.e. SlimDX is no longer around) @@ -94,7 +89,6 @@ static Program() private static int Main(string[] args) { var exitCode = SubMain(args); - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { Console.WriteLine("BizHawk has completed its shutdown routines, killing process..."); diff --git a/src/BizHawk.Client.EmuHawk/Sound/Sound.cs b/src/BizHawk.Client.EmuHawk/Sound/Sound.cs index 02ab74b29c5..e50d35c49ba 100644 --- a/src/BizHawk.Client.EmuHawk/Sound/Sound.cs +++ b/src/BizHawk.Client.EmuHawk/Sound/Sound.cs @@ -154,7 +154,6 @@ public void HandleInitializationOrUnderrun(bool isUnderrun, ref int samplesNeede public void UpdateSound(float atten, bool isSecondaryThrottlingDisabled) { - if (!Config.SoundEnabled || !IsStarted || _bufferedProvider == null || _disposed) { _bufferedProvider?.DiscardSamples(); @@ -189,7 +188,6 @@ public void UpdateSound(float atten, bool isSecondaryThrottlingDisabled) { return; } - int samplesPerMs = SampleRate / 1000; int outputThresholdMs = 20; while (sampleCount > samplesNeeded) diff --git a/src/BizHawk.Client.EmuHawk/config/SoundConfig.cs b/src/BizHawk.Client.EmuHawk/config/SoundConfig.cs index 413f9b0adb9..654d44048f8 100644 --- a/src/BizHawk.Client.EmuHawk/config/SoundConfig.cs +++ b/src/BizHawk.Client.EmuHawk/config/SoundConfig.cs @@ -22,7 +22,6 @@ public SoundConfig(IDialogController dialogController, Config config, Func Date: Sun, 10 Mar 2024 13:16:58 -0400 Subject: [PATCH 6/9] simplified the logic used in my if statements --- src/BizHawk.Client.EmuHawk/MainForm.cs | 32 ++++++++----------- .../config/SoundConfig.cs | 6 +--- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index f07ddb38615..ef3c602d4fe 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -3304,30 +3304,26 @@ private void StepRunLoop_Core(bool force = false) // Mutes the game if EmuHawk is unfocused or minimized // An option in the sound settings needs to be turned on for this to work. - if (Config.MuteInBG) { - if(WindowState == FormWindowState.Minimized || Form.ActiveForm == null) { - Sound.StopSound(); - } - else { - Sound.StartSound(); - } - } else { + if (Config.MuteInBG && (WindowState == FormWindowState.Minimized || Form.ActiveForm == null)) + { + Sound.StopSound(); + } + else + { Sound.StartSound(); } // Mutes the game if the current FPS reaches the threshold chosen by the user or lower // An option in the sound settings needs to be turned on for this to work. - if(Config.MuteOnLag) { - if (_lastFps <= (double)Config.FPSThreshold) - { - Sound.StopSound(); - } - else - { - Sound.StartSound(); - } + if (Config.MuteOnLag && _lastFps <= Config.FPSThreshold) + { + Sound.StopSound(); + } + else + { + Sound.StartSound(); } - + Sound.UpdateSound(atten, DisableSecondaryThrottling); } diff --git a/src/BizHawk.Client.EmuHawk/config/SoundConfig.cs b/src/BizHawk.Client.EmuHawk/config/SoundConfig.cs index 654d44048f8..14ce350da10 100644 --- a/src/BizHawk.Client.EmuHawk/config/SoundConfig.cs +++ b/src/BizHawk.Client.EmuHawk/config/SoundConfig.cs @@ -154,11 +154,7 @@ private void nudRWFF_ValueChanged(object sender, EventArgs e) private void muteOnLag_CheckedChanged(object sender, EventArgs e) { - if(cbMuteOnLag.Checked) { - FpsThresholdNumeric.Enabled = true; - } else { - FpsThresholdNumeric.Enabled = false; - } + FpsThresholdNumeric.Enabled = ((CheckBox)sender).Checked; } } } From daf34b05229a83c6b6c05ee35acb9e0fce1acbd4 Mon Sep 17 00:00:00 2001 From: FredTheHunter Date: Sun, 10 Mar 2024 13:33:45 -0400 Subject: [PATCH 7/9] Changed the FPSThreshold to a percentage --- src/BizHawk.Client.Common/config/Config.cs | 2 +- src/BizHawk.Client.EmuHawk/MainForm.cs | 2 +- .../config/SoundConfig.Designer.cs | 42 +++++++++---------- .../config/SoundConfig.cs | 4 +- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/BizHawk.Client.Common/config/Config.cs b/src/BizHawk.Client.Common/config/Config.cs index bee8c51bf85..83057fd9f71 100644 --- a/src/BizHawk.Client.Common/config/Config.cs +++ b/src/BizHawk.Client.Common/config/Config.cs @@ -259,7 +259,7 @@ public void ResolveDefaults() public bool MuteOnLag { get; set; } = false; - public int FPSThreshold { get; set; } = 56; + public int FPSThresholdPercentage { get; set; } = 90; // Lua public RecentFiles RecentLua { get; set; } = new RecentFiles(8); diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index ef3c602d4fe..2a867c4b7e8 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -3315,7 +3315,7 @@ private void StepRunLoop_Core(bool force = false) // Mutes the game if the current FPS reaches the threshold chosen by the user or lower // An option in the sound settings needs to be turned on for this to work. - if (Config.MuteOnLag && _lastFps <= Config.FPSThreshold) + if (Config.MuteOnLag && _lastFps <= 60 * ((double)Config.FPSThresholdPercentage / 100)) { Sound.StopSound(); } diff --git a/src/BizHawk.Client.EmuHawk/config/SoundConfig.Designer.cs b/src/BizHawk.Client.EmuHawk/config/SoundConfig.Designer.cs index 6ebcf0489c1..60dc4d3319d 100644 --- a/src/BizHawk.Client.EmuHawk/config/SoundConfig.Designer.cs +++ b/src/BizHawk.Client.EmuHawk/config/SoundConfig.Designer.cs @@ -35,6 +35,8 @@ private void InitializeComponent() this.nudRWFF = new System.Windows.Forms.NumericUpDown(); this.cbEnableRWFF = new System.Windows.Forms.CheckBox(); this.tbRWFF = new System.Windows.Forms.TrackBar(); + this.label2 = new BizHawk.WinForms.Controls.LocLabelEx(); + this.label1 = new BizHawk.WinForms.Controls.LocLabelEx(); this.tbNormal = new System.Windows.Forms.TrackBar(); this.nudNormal = new System.Windows.Forms.NumericUpDown(); this.listBoxSoundDevices = new System.Windows.Forms.ListBox(); @@ -53,8 +55,6 @@ private void InitializeComponent() this.BufferSizeUnitsLabel = new BizHawk.WinForms.Controls.LocLabelEx(); this.BufferSizeLabel = new BizHawk.WinForms.Controls.LocLabelEx(); this.SoundDeviceLabel = new BizHawk.WinForms.Controls.LocLabelEx(); - this.label2 = new BizHawk.WinForms.Controls.LocLabelEx(); - this.label1 = new BizHawk.WinForms.Controls.LocLabelEx(); this.grpSoundVol.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.nudRWFF)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.tbRWFF)).BeginInit(); @@ -159,6 +159,22 @@ private void InitializeComponent() this.tbRWFF.TickFrequency = 10; this.tbRWFF.Scroll += new System.EventHandler(this.TbRwff_Scroll); // + // label2 + // + this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.label2.Location = new System.Drawing.Point(149, 100); + this.label2.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0); + this.label2.Name = "label2"; + this.label2.Text = "RW && FF"; + // + // label1 + // + this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.label1.Location = new System.Drawing.Point(16, 100); + this.label1.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0); + this.label1.Name = "label1"; + this.label1.Text = "Normal"; + // // tbNormal // this.tbNormal.LargeChange = 10; @@ -328,7 +344,7 @@ private void InitializeComponent() this.FpsThresholdNumeric.Size = new System.Drawing.Size(120, 38); this.FpsThresholdNumeric.TabIndex = 10; this.FpsThresholdNumeric.Value = new decimal(new int[] { - 56, + 100, 0, 0, 0}); @@ -336,10 +352,10 @@ private void InitializeComponent() // fpsThresholdLabel // this.fpsThresholdLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.fpsThresholdLabel.Location = new System.Drawing.Point(648, 262); + this.fpsThresholdLabel.Location = new System.Drawing.Point(628, 262); this.fpsThresholdLabel.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0); this.fpsThresholdLabel.Name = "fpsThresholdLabel"; - this.fpsThresholdLabel.Text = "FPS Threshold for Mute on Lag\r\n"; + this.fpsThresholdLabel.Text = "FPS Threshold % for Mute on Lag\r\n"; // // label3 // @@ -372,22 +388,6 @@ private void InitializeComponent() this.SoundDeviceLabel.Name = "SoundDeviceLabel"; this.SoundDeviceLabel.Text = "Sound Device:"; // - // label2 - // - this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.label2.Location = new System.Drawing.Point(149, 100); - this.label2.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0); - this.label2.Name = "label2"; - this.label2.Text = "RW && FF"; - // - // label1 - // - this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.label1.Location = new System.Drawing.Point(16, 100); - this.label1.Margin = new System.Windows.Forms.Padding(8, 0, 8, 0); - this.label1.Name = "label1"; - this.label1.Text = "Normal"; - // // SoundConfig // this.AcceptButton = this.OK; diff --git a/src/BizHawk.Client.EmuHawk/config/SoundConfig.cs b/src/BizHawk.Client.EmuHawk/config/SoundConfig.cs index 14ce350da10..d27e496290e 100644 --- a/src/BizHawk.Client.EmuHawk/config/SoundConfig.cs +++ b/src/BizHawk.Client.EmuHawk/config/SoundConfig.cs @@ -46,7 +46,7 @@ private void SoundConfig_Load(object sender, EventArgs e) nudRWFF.Value = _config.SoundVolumeRWFF; cbMuteInBG.Checked = _config.MuteInBG; cbMuteOnLag.Checked = _config.MuteOnLag; - FpsThresholdNumeric.Value = _config.FPSThreshold; + FpsThresholdNumeric.Value = _config.FPSThresholdPercentage; FpsThresholdNumeric.Enabled = _config.MuteOnLag; UpdateSoundDialog(); _programmaticallyChangingValue = false; @@ -81,7 +81,7 @@ private void Ok_Click(object sender, EventArgs e) _config.SoundDevice = (string)listBoxSoundDevices.SelectedItem ?? ""; _config.MuteInBG = cbMuteInBG.Checked; _config.MuteOnLag = cbMuteOnLag.Checked; - _config.FPSThreshold = (int)FpsThresholdNumeric.Value; + _config.FPSThresholdPercentage = (int)FpsThresholdNumeric.Value; DialogResult = DialogResult.OK; } From 51e8a2b865e763b52abe10358878967e729438cb Mon Sep 17 00:00:00 2001 From: FredTheHunter Date: Wed, 13 Mar 2024 13:44:47 -0400 Subject: [PATCH 8/9] removed empty files --- firmware.zip | 0 lua.zip | 0 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 firmware.zip delete mode 100644 lua.zip diff --git a/firmware.zip b/firmware.zip deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/lua.zip b/lua.zip deleted file mode 100644 index e69de29bb2d..00000000000 From 1fe4748e1b4a90f1730a06520e92a8e258db1697 Mon Sep 17 00:00:00 2001 From: FredTheHunter Date: Wed, 13 Mar 2024 13:49:26 -0400 Subject: [PATCH 9/9] made it so the base fps is dynamically chosen depending on the platform --- src/BizHawk.Client.EmuHawk/MainForm.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index 2a867c4b7e8..fa9ad861dfa 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -3315,7 +3315,7 @@ private void StepRunLoop_Core(bool force = false) // Mutes the game if the current FPS reaches the threshold chosen by the user or lower // An option in the sound settings needs to be turned on for this to work. - if (Config.MuteOnLag && _lastFps <= 60 * ((double)Config.FPSThresholdPercentage / 100)) + if (Config.MuteOnLag && _lastFps <= PlatformFrameRates.GetFrameRate(Emulator.SystemId, Emulator.HasRegions() && Emulator.AsRegionable().Region is DisplayType.PAL) * ((double)Config.FPSThresholdPercentage / 100)) { Sound.StopSound(); }