From a4e19b5df1290794cda202cccc4ed613b2843e6d Mon Sep 17 00:00:00 2001 From: Sour Date: Tue, 2 Jan 2018 15:08:07 -0500 Subject: [PATCH] Debugger: Added checkboxes to mute specific channels in APU Viewer --- Core/EmulationSettings.h | 2 + GUI.NET/Debugger/frmApuViewer.Designer.cs | 244 +++++++++++++++++++++- GUI.NET/Debugger/frmApuViewer.cs | 26 ++- 3 files changed, 263 insertions(+), 9 deletions(-) diff --git a/Core/EmulationSettings.h b/Core/EmulationSettings.h index 8898ec95..811dfc22 100644 --- a/Core/EmulationSettings.h +++ b/Core/EmulationSettings.h @@ -750,11 +750,13 @@ public: static void SetChannelVolume(AudioChannel channel, double volume) { _channelVolume[(int)channel] = volume; + _audioSettingsChanged = true; } static void SetMasterVolume(double volume) { _masterVolume = volume; + _audioSettingsChanged = true; } static void SetChannelPanning(AudioChannel channel, double panning) diff --git a/GUI.NET/Debugger/frmApuViewer.Designer.cs b/GUI.NET/Debugger/frmApuViewer.Designer.cs index f0471f65..89b3f5c4 100644 --- a/GUI.NET/Debugger/frmApuViewer.Designer.cs +++ b/GUI.NET/Debugger/frmApuViewer.Designer.cs @@ -29,6 +29,19 @@ { this.components = new System.ComponentModel.Container(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.grpChannelControl = new System.Windows.Forms.GroupBox(); + this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); + this.chkFds = new System.Windows.Forms.CheckBox(); + this.chkSquare1 = new System.Windows.Forms.CheckBox(); + this.chkSquare2 = new System.Windows.Forms.CheckBox(); + this.chkTriangle = new System.Windows.Forms.CheckBox(); + this.chkNoise = new System.Windows.Forms.CheckBox(); + this.chkMmc5 = new System.Windows.Forms.CheckBox(); + this.chkNamco = new System.Windows.Forms.CheckBox(); + this.chkVrc7 = new System.Windows.Forms.CheckBox(); + this.chkDmc = new System.Windows.Forms.CheckBox(); + this.chkSunsoft = new System.Windows.Forms.CheckBox(); + this.chkVrc6 = new System.Windows.Forms.CheckBox(); this.grpSquare1 = new System.Windows.Forms.GroupBox(); this.ctrlSquareInfo1 = new Mesen.GUI.Debugger.Controls.ctrlSquareInfo(); this.grpSquare2 = new System.Windows.Forms.GroupBox(); @@ -43,6 +56,8 @@ this.ctrlFrameCounterInfo = new Mesen.GUI.Debugger.Controls.ctrlFrameCounterInfo(); this.tmrUpdate = new System.Windows.Forms.Timer(this.components); this.tableLayoutPanel1.SuspendLayout(); + this.grpChannelControl.SuspendLayout(); + this.tableLayoutPanel2.SuspendLayout(); this.grpSquare1.SuspendLayout(); this.grpSquare2.SuspendLayout(); this.grpTriangle.SuspendLayout(); @@ -53,10 +68,12 @@ // // tableLayoutPanel1 // - this.tableLayoutPanel1.ColumnCount = 3; + this.tableLayoutPanel1.ColumnCount = 4; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel1.Controls.Add(this.grpChannelControl, 2, 2); this.tableLayoutPanel1.Controls.Add(this.grpSquare1, 0, 0); this.tableLayoutPanel1.Controls.Add(this.grpSquare2, 0, 1); this.tableLayoutPanel1.Controls.Add(this.grpTriangle, 1, 0); @@ -71,11 +88,205 @@ this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); - this.tableLayoutPanel1.Size = new System.Drawing.Size(990, 533); + this.tableLayoutPanel1.Size = new System.Drawing.Size(987, 533); this.tableLayoutPanel1.TabIndex = 0; // + // grpChannelControl + // + this.grpChannelControl.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.grpChannelControl.Controls.Add(this.tableLayoutPanel2); + this.grpChannelControl.Location = new System.Drawing.Point(714, 408); + this.grpChannelControl.Name = "grpChannelControl"; + this.grpChannelControl.Size = new System.Drawing.Size(273, 121); + this.grpChannelControl.TabIndex = 8; + this.grpChannelControl.TabStop = false; + this.grpChannelControl.Text = "Channel Control (uncheck to mute)"; + // + // tableLayoutPanel2 + // + this.tableLayoutPanel2.ColumnCount = 3; + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F)); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33334F)); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33334F)); + this.tableLayoutPanel2.Controls.Add(this.chkFds, 1, 0); + this.tableLayoutPanel2.Controls.Add(this.chkSquare1, 0, 0); + this.tableLayoutPanel2.Controls.Add(this.chkSquare2, 0, 1); + this.tableLayoutPanel2.Controls.Add(this.chkTriangle, 0, 2); + this.tableLayoutPanel2.Controls.Add(this.chkNoise, 0, 3); + this.tableLayoutPanel2.Controls.Add(this.chkMmc5, 1, 1); + this.tableLayoutPanel2.Controls.Add(this.chkNamco, 1, 2); + this.tableLayoutPanel2.Controls.Add(this.chkVrc7, 2, 1); + this.tableLayoutPanel2.Controls.Add(this.chkDmc, 0, 4); + this.tableLayoutPanel2.Controls.Add(this.chkSunsoft, 1, 3); + this.tableLayoutPanel2.Controls.Add(this.chkVrc6, 2, 0); + this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel2.Location = new System.Drawing.Point(3, 16); + this.tableLayoutPanel2.Name = "tableLayoutPanel2"; + this.tableLayoutPanel2.RowCount = 5; + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel2.Size = new System.Drawing.Size(267, 102); + this.tableLayoutPanel2.TabIndex = 0; + // + // chkFds + // + this.chkFds.AutoSize = true; + this.chkFds.Checked = true; + this.chkFds.CheckState = System.Windows.Forms.CheckState.Checked; + this.chkFds.Location = new System.Drawing.Point(91, 0); + this.chkFds.Margin = new System.Windows.Forms.Padding(3, 0, 3, 3); + this.chkFds.Name = "chkFds"; + this.chkFds.Size = new System.Drawing.Size(47, 17); + this.chkFds.TabIndex = 5; + this.chkFds.Text = "FDS"; + this.chkFds.UseVisualStyleBackColor = true; + this.chkFds.CheckedChanged += new System.EventHandler(this.chkSoundChannel_CheckedChanged); + // + // chkSquare1 + // + this.chkSquare1.AutoSize = true; + this.chkSquare1.Checked = true; + this.chkSquare1.CheckState = System.Windows.Forms.CheckState.Checked; + this.chkSquare1.Location = new System.Drawing.Point(3, 0); + this.chkSquare1.Margin = new System.Windows.Forms.Padding(3, 0, 3, 3); + this.chkSquare1.Name = "chkSquare1"; + this.chkSquare1.Size = new System.Drawing.Size(69, 17); + this.chkSquare1.TabIndex = 0; + this.chkSquare1.Text = "Square 1"; + this.chkSquare1.UseVisualStyleBackColor = true; + this.chkSquare1.CheckedChanged += new System.EventHandler(this.chkSoundChannel_CheckedChanged); + // + // chkSquare2 + // + this.chkSquare2.AutoSize = true; + this.chkSquare2.Checked = true; + this.chkSquare2.CheckState = System.Windows.Forms.CheckState.Checked; + this.chkSquare2.Location = new System.Drawing.Point(3, 20); + this.chkSquare2.Margin = new System.Windows.Forms.Padding(3, 0, 3, 3); + this.chkSquare2.Name = "chkSquare2"; + this.chkSquare2.Size = new System.Drawing.Size(69, 17); + this.chkSquare2.TabIndex = 1; + this.chkSquare2.Text = "Square 2"; + this.chkSquare2.UseVisualStyleBackColor = true; + this.chkSquare2.CheckedChanged += new System.EventHandler(this.chkSoundChannel_CheckedChanged); + // + // chkTriangle + // + this.chkTriangle.AutoSize = true; + this.chkTriangle.Checked = true; + this.chkTriangle.CheckState = System.Windows.Forms.CheckState.Checked; + this.chkTriangle.Location = new System.Drawing.Point(3, 40); + this.chkTriangle.Margin = new System.Windows.Forms.Padding(3, 0, 3, 3); + this.chkTriangle.Name = "chkTriangle"; + this.chkTriangle.Size = new System.Drawing.Size(64, 17); + this.chkTriangle.TabIndex = 2; + this.chkTriangle.Text = "Triangle"; + this.chkTriangle.UseVisualStyleBackColor = true; + this.chkTriangle.CheckedChanged += new System.EventHandler(this.chkSoundChannel_CheckedChanged); + // + // chkNoise + // + this.chkNoise.AutoSize = true; + this.chkNoise.Checked = true; + this.chkNoise.CheckState = System.Windows.Forms.CheckState.Checked; + this.chkNoise.Location = new System.Drawing.Point(3, 60); + this.chkNoise.Margin = new System.Windows.Forms.Padding(3, 0, 3, 3); + this.chkNoise.Name = "chkNoise"; + this.chkNoise.Size = new System.Drawing.Size(53, 17); + this.chkNoise.TabIndex = 3; + this.chkNoise.Text = "Noise"; + this.chkNoise.UseVisualStyleBackColor = true; + this.chkNoise.CheckedChanged += new System.EventHandler(this.chkSoundChannel_CheckedChanged); + // + // chkMmc5 + // + this.chkMmc5.AutoSize = true; + this.chkMmc5.Checked = true; + this.chkMmc5.CheckState = System.Windows.Forms.CheckState.Checked; + this.chkMmc5.Location = new System.Drawing.Point(91, 20); + this.chkMmc5.Margin = new System.Windows.Forms.Padding(3, 0, 3, 3); + this.chkMmc5.Name = "chkMmc5"; + this.chkMmc5.Size = new System.Drawing.Size(57, 17); + this.chkMmc5.TabIndex = 9; + this.chkMmc5.Text = "MMC5"; + this.chkMmc5.UseVisualStyleBackColor = true; + this.chkMmc5.CheckedChanged += new System.EventHandler(this.chkSoundChannel_CheckedChanged); + // + // chkNamco + // + this.chkNamco.AutoSize = true; + this.chkNamco.Checked = true; + this.chkNamco.CheckState = System.Windows.Forms.CheckState.Checked; + this.chkNamco.Location = new System.Drawing.Point(91, 40); + this.chkNamco.Margin = new System.Windows.Forms.Padding(3, 0, 3, 3); + this.chkNamco.Name = "chkNamco"; + this.chkNamco.Size = new System.Drawing.Size(60, 17); + this.chkNamco.TabIndex = 6; + this.chkNamco.Text = "Namco"; + this.chkNamco.UseVisualStyleBackColor = true; + this.chkNamco.CheckedChanged += new System.EventHandler(this.chkSoundChannel_CheckedChanged); + // + // chkVrc7 + // + this.chkVrc7.AutoSize = true; + this.chkVrc7.Checked = true; + this.chkVrc7.CheckState = System.Windows.Forms.CheckState.Checked; + this.chkVrc7.Location = new System.Drawing.Point(180, 20); + this.chkVrc7.Margin = new System.Windows.Forms.Padding(3, 0, 3, 3); + this.chkVrc7.Name = "chkVrc7"; + this.chkVrc7.Size = new System.Drawing.Size(54, 17); + this.chkVrc7.TabIndex = 8; + this.chkVrc7.Text = "VRC7"; + this.chkVrc7.UseVisualStyleBackColor = true; + this.chkVrc7.CheckedChanged += new System.EventHandler(this.chkSoundChannel_CheckedChanged); + // + // chkDmc + // + this.chkDmc.AutoSize = true; + this.chkDmc.Checked = true; + this.chkDmc.CheckState = System.Windows.Forms.CheckState.Checked; + this.chkDmc.Location = new System.Drawing.Point(3, 80); + this.chkDmc.Margin = new System.Windows.Forms.Padding(3, 0, 3, 3); + this.chkDmc.Name = "chkDmc"; + this.chkDmc.Size = new System.Drawing.Size(50, 17); + this.chkDmc.TabIndex = 4; + this.chkDmc.Text = "DMC"; + this.chkDmc.UseVisualStyleBackColor = true; + this.chkDmc.CheckedChanged += new System.EventHandler(this.chkSoundChannel_CheckedChanged); + // + // chkSunsoft + // + this.chkSunsoft.AutoSize = true; + this.chkSunsoft.Checked = true; + this.chkSunsoft.CheckState = System.Windows.Forms.CheckState.Checked; + this.chkSunsoft.Location = new System.Drawing.Point(91, 60); + this.chkSunsoft.Margin = new System.Windows.Forms.Padding(3, 0, 3, 3); + this.chkSunsoft.Name = "chkSunsoft"; + this.chkSunsoft.Size = new System.Drawing.Size(62, 17); + this.chkSunsoft.TabIndex = 10; + this.chkSunsoft.Text = "Sunsoft"; + this.chkSunsoft.UseVisualStyleBackColor = true; + this.chkSunsoft.CheckedChanged += new System.EventHandler(this.chkSoundChannel_CheckedChanged); + // + // chkVrc6 + // + this.chkVrc6.AutoSize = true; + this.chkVrc6.Checked = true; + this.chkVrc6.CheckState = System.Windows.Forms.CheckState.Checked; + this.chkVrc6.Location = new System.Drawing.Point(180, 0); + this.chkVrc6.Margin = new System.Windows.Forms.Padding(3, 0, 3, 3); + this.chkVrc6.Name = "chkVrc6"; + this.chkVrc6.Size = new System.Drawing.Size(54, 17); + this.chkVrc6.TabIndex = 7; + this.chkVrc6.Text = "VRC6"; + this.chkVrc6.UseVisualStyleBackColor = true; + this.chkVrc6.CheckedChanged += new System.EventHandler(this.chkSoundChannel_CheckedChanged); + // // grpSquare1 // this.grpSquare1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) @@ -123,6 +334,7 @@ this.grpTriangle.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.tableLayoutPanel1.SetColumnSpan(this.grpTriangle, 2); this.grpTriangle.Controls.Add(this.ctrlTriangleInfo); this.grpTriangle.Location = new System.Drawing.Point(558, 3); this.grpTriangle.Name = "grpTriangle"; @@ -144,6 +356,7 @@ this.grpNoise.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.tableLayoutPanel1.SetColumnSpan(this.grpNoise, 2); this.grpNoise.Controls.Add(this.ctrlNoiseInfo); this.grpNoise.Location = new System.Drawing.Point(558, 205); this.grpNoise.Name = "grpNoise"; @@ -189,17 +402,16 @@ this.grpFrameCounter.Controls.Add(this.ctrlFrameCounterInfo); this.grpFrameCounter.Location = new System.Drawing.Point(558, 408); this.grpFrameCounter.Name = "grpFrameCounter"; - this.grpFrameCounter.Size = new System.Drawing.Size(429, 121); + this.grpFrameCounter.Size = new System.Drawing.Size(150, 121); this.grpFrameCounter.TabIndex = 7; this.grpFrameCounter.TabStop = false; this.grpFrameCounter.Text = "Frame Counter"; // // ctrlFrameCounterInfo // - this.ctrlFrameCounterInfo.Dock = System.Windows.Forms.DockStyle.Fill; this.ctrlFrameCounterInfo.Location = new System.Drawing.Point(3, 16); this.ctrlFrameCounterInfo.Name = "ctrlFrameCounterInfo"; - this.ctrlFrameCounterInfo.Size = new System.Drawing.Size(423, 102); + this.ctrlFrameCounterInfo.Size = new System.Drawing.Size(165, 102); this.ctrlFrameCounterInfo.TabIndex = 0; // // tmrUpdate @@ -211,7 +423,7 @@ // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(990, 533); + this.ClientSize = new System.Drawing.Size(987, 533); this.Controls.Add(this.tableLayoutPanel1); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.MaximizeBox = false; @@ -219,6 +431,9 @@ this.Name = "frmApuViewer"; this.Text = "APU Viewer"; this.tableLayoutPanel1.ResumeLayout(false); + this.grpChannelControl.ResumeLayout(false); + this.tableLayoutPanel2.ResumeLayout(false); + this.tableLayoutPanel2.PerformLayout(); this.grpSquare1.ResumeLayout(false); this.grpSquare2.ResumeLayout(false); this.grpTriangle.ResumeLayout(false); @@ -245,5 +460,18 @@ private Controls.ctrlDmcInfo ctrlDmcInfo; private System.Windows.Forms.GroupBox grpFrameCounter; private Controls.ctrlFrameCounterInfo ctrlFrameCounterInfo; + private System.Windows.Forms.GroupBox grpChannelControl; + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2; + private System.Windows.Forms.CheckBox chkFds; + private System.Windows.Forms.CheckBox chkSquare1; + private System.Windows.Forms.CheckBox chkSquare2; + private System.Windows.Forms.CheckBox chkTriangle; + private System.Windows.Forms.CheckBox chkNoise; + private System.Windows.Forms.CheckBox chkDmc; + private System.Windows.Forms.CheckBox chkMmc5; + private System.Windows.Forms.CheckBox chkNamco; + private System.Windows.Forms.CheckBox chkVrc7; + private System.Windows.Forms.CheckBox chkVrc6; + private System.Windows.Forms.CheckBox chkSunsoft; } } \ No newline at end of file diff --git a/GUI.NET/Debugger/frmApuViewer.cs b/GUI.NET/Debugger/frmApuViewer.cs index 59342431..d04ccec2 100644 --- a/GUI.NET/Debugger/frmApuViewer.cs +++ b/GUI.NET/Debugger/frmApuViewer.cs @@ -1,4 +1,5 @@ -using Mesen.GUI.Forms; +using Mesen.GUI.Config; +using Mesen.GUI.Forms; using System; using System.Collections.Generic; using System.ComponentModel; @@ -22,6 +23,14 @@ namespace Mesen.GUI.Debugger } } + protected override void OnFormClosed(FormClosedEventArgs e) + { + base.OnFormClosed(e); + + //Restore normal volume settings + AudioInfo.ApplyConfig(); + } + private void tmrUpdate_Tick(object sender, EventArgs e) { ApuState state = new ApuState(); @@ -34,5 +43,20 @@ namespace Mesen.GUI.Debugger ctrlDmcInfo.ProcessState(ref state.Dmc); ctrlFrameCounterInfo.ProcessState(ref state.FrameCounter); } + + private void chkSoundChannel_CheckedChanged(object sender, EventArgs e) + { + InteropEmu.SetChannelVolume(AudioChannel.Square1, chkSquare1.Checked ? 1 : 0); + InteropEmu.SetChannelVolume(AudioChannel.Square2, chkSquare2.Checked ? 1 : 0); + InteropEmu.SetChannelVolume(AudioChannel.Triangle, chkTriangle.Checked ? 1 : 0); + InteropEmu.SetChannelVolume(AudioChannel.Noise, chkNoise.Checked ? 1 : 0); + InteropEmu.SetChannelVolume(AudioChannel.DMC, chkDmc.Checked ? 1 : 0); + InteropEmu.SetChannelVolume(AudioChannel.FDS, chkFds.Checked ? 1 : 0); + InteropEmu.SetChannelVolume(AudioChannel.Namco163, chkNamco.Checked ? 1 : 0); + InteropEmu.SetChannelVolume(AudioChannel.VRC6, chkVrc6.Checked ? 1 : 0); + InteropEmu.SetChannelVolume(AudioChannel.VRC7, chkVrc7.Checked ? 1 : 0); + InteropEmu.SetChannelVolume(AudioChannel.MMC5, chkMmc5.Checked ? 1 : 0); + InteropEmu.SetChannelVolume(AudioChannel.Sunsoft5B, chkSunsoft.Checked ? 1 : 0); + } } }