diff --git a/src/BizHawk.Client.Common/config/Config.cs b/src/BizHawk.Client.Common/config/Config.cs index 37cb1fe179e..83057fd9f71 100644 --- a/src/BizHawk.Client.Common/config/Config.cs +++ b/src/BizHawk.Client.Common/config/Config.cs @@ -255,6 +255,12 @@ public void ResolveDefaults() public string SoundDevice { get; set; } = ""; public int SoundBufferSizeMs { get; set; } = 100; + public bool MuteInBG { get; set; } = false; + + public bool MuteOnLag { get; set; } = false; + + public int FPSThresholdPercentage { get; set; } = 90; + // 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..fa9ad861dfa 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -3302,6 +3302,28 @@ 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 && (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 && _lastFps <= PlatformFrameRates.GetFrameRate(Emulator.SystemId, Emulator.HasRegions() && Emulator.AsRegionable().Region is DisplayType.PAL) * ((double)Config.FPSThresholdPercentage / 100)) + { + Sound.StopSound(); + } + else + { + Sound.StartSound(); + } + Sound.UpdateSound(atten, DisableSecondaryThrottling); } diff --git a/src/BizHawk.Client.EmuHawk/Program.cs b/src/BizHawk.Client.EmuHawk/Program.cs index 88eaf12f71e..38a229eaf5e 100644 --- a/src/BizHawk.Client.EmuHawk/Program.cs +++ b/src/BizHawk.Client.EmuHawk/Program.cs @@ -33,7 +33,7 @@ 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) diff --git a/src/BizHawk.Client.EmuHawk/Sound/Sound.cs b/src/BizHawk.Client.EmuHawk/Sound/Sound.cs index fe4886b5312..e50d35c49ba 100644 --- a/src/BizHawk.Client.EmuHawk/Sound/Sound.cs +++ b/src/BizHawk.Client.EmuHawk/Sound/Sound.cs @@ -188,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.Designer.cs b/src/BizHawk.Client.EmuHawk/config/SoundConfig.Designer.cs index fc60c8a5a59..60dc4d3319d 100644 --- a/src/BizHawk.Client.EmuHawk/config/SoundConfig.Designer.cs +++ b/src/BizHawk.Client.EmuHawk/config/SoundConfig.Designer.cs @@ -28,330 +28,409 @@ 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.BufferSizeNumeric = new System.Windows.Forms.NumericUpDown(); + 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.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.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(); + ((System.ComponentModel.ISupportInitialize)(this.FpsThresholdNumeric)).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(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); + 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(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); + 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, 354); + this.listBoxSoundDevices.Margin = new System.Windows.Forms.Padding(8, 7, 8, 7); + this.listBoxSoundDevices.Name = "listBoxSoundDevices"; + this.listBoxSoundDevices.Size = new System.Drawing.Size(820, 438); + this.listBoxSoundDevices.TabIndex = 8; + // + // 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, 806); + 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(); + // + // 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); + // + // 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[] { + 100, + 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(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"; + // + // 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:"; + // + // 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(1226, 964); + this.Controls.Add(this.fpsThresholdLabel); + 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); + 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(); + ((System.ComponentModel.ISupportInitialize)(this.FpsThresholdNumeric)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); } @@ -380,5 +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 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 093a3d94c78..d27e496290e 100644 --- a/src/BizHawk.Client.EmuHawk/config/SoundConfig.cs +++ b/src/BizHawk.Client.EmuHawk/config/SoundConfig.cs @@ -44,8 +44,11 @@ private void SoundConfig_Load(object sender, EventArgs e) nudNormal.Value = _config.SoundVolume; tbRWFF.Value = _config.SoundVolumeRWFF; nudRWFF.Value = _config.SoundVolumeRWFF; + cbMuteInBG.Checked = _config.MuteInBG; + cbMuteOnLag.Checked = _config.MuteOnLag; + FpsThresholdNumeric.Value = _config.FPSThresholdPercentage; + FpsThresholdNumeric.Enabled = _config.MuteOnLag; UpdateSoundDialog(); - _programmaticallyChangingValue = false; } @@ -76,6 +79,9 @@ private void Ok_Click(object sender, EventArgs e) _config.SoundVolume = tbNormal.Value; _config.SoundVolumeRWFF = tbRWFF.Value; _config.SoundDevice = (string)listBoxSoundDevices.SelectedItem ?? ""; + _config.MuteInBG = cbMuteInBG.Checked; + _config.MuteOnLag = cbMuteOnLag.Checked; + _config.FPSThresholdPercentage = (int)FpsThresholdNumeric.Value; DialogResult = DialogResult.OK; } @@ -145,5 +151,10 @@ private void nudRWFF_ValueChanged(object sender, EventArgs e) { tbRWFF.Value = (int)nudRWFF.Value; } + + private void muteOnLag_CheckedChanged(object sender, EventArgs e) + { + FpsThresholdNumeric.Enabled = ((CheckBox)sender).Checked; + } } }