NES: volume control on each channel

This commit is contained in:
goyuken 2013-05-10 18:38:58 +00:00
parent 99615d9afd
commit 6849f72baf
6 changed files with 259 additions and 106 deletions

View File

@ -24,11 +24,11 @@ namespace BizHawk.Emulation.Consoles.Nintendo
{
public static bool CFG_DECLICK = true;
public bool EnableSquare1 = false;
public bool EnableSquare2 = false;
public bool EnableTriangle = true;
public bool EnableNoise = false;
public bool EnableDMC = true;
public int Square1V = 376;
public int Square2V = 376;
public int TriangleV = 426;
public int NoiseV = 247;
public int DMCV = 167;
public bool recalculate = false;
@ -43,11 +43,11 @@ namespace BizHawk.Emulation.Consoles.Nintendo
pulse[1] = new PulseUnit(this, 1);
if (old != null)
{
EnableSquare1 = old.EnableSquare1;
EnableSquare2 = old.EnableSquare2;
EnableTriangle = old.EnableTriangle;
EnableNoise = old.EnableNoise;
EnableDMC = old.EnableDMC;
Square1V = old.Square1V;
Square2V = old.Square2V;
TriangleV = old.TriangleV;
NoiseV = old.NoiseV;
DMCV = old.DMCV;
}
}
@ -1138,12 +1138,14 @@ namespace BizHawk.Emulation.Consoles.Nintendo
int s_dmc = dmc.sample;
//int s_ext = 0; //gamepak
/*
if (!EnableSquare1) s_pulse0 = 0;
if (!EnableSquare2) s_pulse1 = 0;
if (!EnableTriangle) s_tri = 0;
if (!EnableNoise) s_noise = 0;
if (!EnableDMC) s_dmc = 0;
*/
//const float NOISEADJUST = 0.5f;
//linear approximation
@ -1153,9 +1155,16 @@ namespace BizHawk.Emulation.Consoles.Nintendo
//this needs to leave enough headroom for straying DC bias due to the DMC unit getting stuck outputs. smb3 is bad about that.
//int mix = (int)(50000 * output);
int mix = Square1V * s_pulse0
+ Square2V * s_pulse1
+ TriangleV * s_tri
+ NoiseV * s_noise
+ DMCV * s_dmc;
/*
int pulse_out = 376 * (s_pulse0 + s_pulse1);
int tnd_out = 426 * s_tri + 247 * s_noise + 167 * s_dmc;
int mix = pulse_out + tnd_out;
*/
//int pulse_out = pulse_table[s_pulse0 + s_pulse1];
//int tnd_out = tnd_table[3 * s_tri + 2 * s_noise + s_dmc];
//int mix = pulse_out + tnd_out;

View File

@ -47,11 +47,11 @@ namespace BizHawk.Emulation.Consoles.Nintendo
private DisplayType _display_type = DisplayType.NTSC;
//Sound config
public void SetSquare1(bool enabled) { apu.EnableSquare1 = enabled; }
public void SetSquare2(bool enabled) { apu.EnableSquare2 = enabled; }
public void SetTriangle(bool enabled) { apu.EnableTriangle = enabled; }
public void SetNoise(bool enabled) { apu.EnableNoise = enabled; }
public void SetDMC(bool enabled) { apu.EnableDMC = enabled; }
public void SetSquare1(int v) { apu.Square1V = v; }
public void SetSquare2(int v) { apu.Square2V = v; }
public void SetTriangle(int v) { apu.TriangleV = v; }
public void SetNoise(int v) { apu.NoiseV = v; }
public void SetDMC(int v) { apu.DMCV = v; }
public void Dispose()
{

View File

@ -789,11 +789,17 @@ namespace BizHawk.MultiClient
public string MoviePlaybackPokeModeBinding = "";
public string ClearFrameBinding = "";
// NES Sound settings
public bool NESEnableSquare1 = true;
public bool NESEnableSquare2 = true;
public bool NESEnableTriangle = true;
public bool NESEnableNoise = true;
public bool NESEnableDMC = true;
public int NESSquare1 = 376;
public int NESSquare2 = 376;
public int NESTriangle = 426;
public int NESNoise = 247;
public int NESDMC = 167;
public const int NESSquare1Max = 376;
public const int NESSquare2Max = 376;
public const int NESTriangleMax = 426;
public const int NESNoiseMax = 247;
public const int NESDMCMax = 167;
// SMS / GameGear Settings
public bool SmsEnableFM = true;

View File

@ -5063,11 +5063,11 @@ namespace BizHawk.MultiClient
public void SetNESSoundChannels()
{
NES nes = Global.Emulator as NES;
nes.SetSquare1(Global.Config.NESEnableSquare1);
nes.SetSquare2(Global.Config.NESEnableSquare2);
nes.SetTriangle(Global.Config.NESEnableTriangle);
nes.SetNoise(Global.Config.NESEnableNoise);
nes.SetDMC(Global.Config.NESEnableDMC);
nes.SetSquare1(Global.Config.NESSquare1);
nes.SetSquare2(Global.Config.NESSquare2);
nes.SetTriangle(Global.Config.NESTriangle);
nes.SetNoise(Global.Config.NESNoise);
nes.SetDMC(Global.Config.NESDMC);
}
private void soundChannelsToolStripMenuItem_Click(object sender, EventArgs e)

View File

@ -30,18 +30,32 @@
{
this.OK = new System.Windows.Forms.Button();
this.Cancel = new System.Windows.Forms.Button();
this.Square1 = new System.Windows.Forms.CheckBox();
this.Triangle = new System.Windows.Forms.CheckBox();
this.Noise = new System.Windows.Forms.CheckBox();
this.Square2 = new System.Windows.Forms.CheckBox();
this.DMC = new System.Windows.Forms.CheckBox();
this.SelectAll = new System.Windows.Forms.CheckBox();
this.trackBar1 = new System.Windows.Forms.TrackBar();
this.trackBar2 = new System.Windows.Forms.TrackBar();
this.trackBar3 = new System.Windows.Forms.TrackBar();
this.trackBar4 = new System.Windows.Forms.TrackBar();
this.trackBar5 = new System.Windows.Forms.TrackBar();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.trackBar2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.trackBar3)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.trackBar4)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.trackBar5)).BeginInit();
this.SuspendLayout();
//
// 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(52, 158);
this.OK.Location = new System.Drawing.Point(41, 262);
this.OK.Name = "OK";
this.OK.Size = new System.Drawing.Size(75, 23);
this.OK.TabIndex = 0;
@ -53,7 +67,7 @@
//
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(133, 158);
this.Cancel.Location = new System.Drawing.Point(122, 262);
this.Cancel.Name = "Cancel";
this.Cancel.Size = new System.Drawing.Size(75, 23);
this.Cancel.TabIndex = 1;
@ -61,66 +75,135 @@
this.Cancel.UseVisualStyleBackColor = true;
this.Cancel.Click += new System.EventHandler(this.Cancel_Click);
//
// Square1
// trackBar1
//
this.Square1.AutoSize = true;
this.Square1.Location = new System.Drawing.Point(12, 12);
this.Square1.Name = "Square1";
this.Square1.Size = new System.Drawing.Size(69, 17);
this.Square1.TabIndex = 2;
this.Square1.Text = "Square 1";
this.Square1.UseVisualStyleBackColor = true;
this.trackBar1.Location = new System.Drawing.Point(12, 12);
this.trackBar1.Name = "trackBar1";
this.trackBar1.Size = new System.Drawing.Size(104, 42);
this.trackBar1.TabIndex = 2;
this.trackBar1.ValueChanged += new System.EventHandler(this.trackBar1_ValueChanged);
//
// Triangle
// trackBar2
//
this.Triangle.AutoSize = true;
this.Triangle.Location = new System.Drawing.Point(12, 58);
this.Triangle.Name = "Triangle";
this.Triangle.Size = new System.Drawing.Size(64, 17);
this.Triangle.TabIndex = 3;
this.Triangle.Text = "Triangle";
this.Triangle.UseVisualStyleBackColor = true;
this.trackBar2.Location = new System.Drawing.Point(12, 60);
this.trackBar2.Name = "trackBar2";
this.trackBar2.Size = new System.Drawing.Size(104, 42);
this.trackBar2.TabIndex = 3;
this.trackBar2.ValueChanged += new System.EventHandler(this.trackBar2_ValueChanged);
//
// Noise
// trackBar3
//
this.Noise.AutoSize = true;
this.Noise.Location = new System.Drawing.Point(12, 81);
this.Noise.Name = "Noise";
this.Noise.Size = new System.Drawing.Size(53, 17);
this.Noise.TabIndex = 5;
this.Noise.Text = "Noise";
this.Noise.UseVisualStyleBackColor = true;
this.trackBar3.Location = new System.Drawing.Point(12, 108);
this.trackBar3.Name = "trackBar3";
this.trackBar3.Size = new System.Drawing.Size(104, 42);
this.trackBar3.TabIndex = 4;
this.trackBar3.ValueChanged += new System.EventHandler(this.trackBar3_ValueChanged);
//
// Square2
// trackBar4
//
this.Square2.AutoSize = true;
this.Square2.Location = new System.Drawing.Point(12, 35);
this.Square2.Name = "Square2";
this.Square2.Size = new System.Drawing.Size(69, 17);
this.Square2.TabIndex = 4;
this.Square2.Text = "Square 2";
this.Square2.UseVisualStyleBackColor = true;
this.trackBar4.Location = new System.Drawing.Point(12, 156);
this.trackBar4.Name = "trackBar4";
this.trackBar4.Size = new System.Drawing.Size(104, 42);
this.trackBar4.TabIndex = 5;
this.trackBar4.ValueChanged += new System.EventHandler(this.trackBar4_ValueChanged);
//
// DMC
// trackBar5
//
this.DMC.AutoSize = true;
this.DMC.Location = new System.Drawing.Point(12, 104);
this.DMC.Name = "DMC";
this.DMC.Size = new System.Drawing.Size(50, 17);
this.DMC.TabIndex = 6;
this.DMC.Text = "DMC";
this.DMC.UseVisualStyleBackColor = true;
this.trackBar5.Location = new System.Drawing.Point(12, 204);
this.trackBar5.Name = "trackBar5";
this.trackBar5.Size = new System.Drawing.Size(104, 42);
this.trackBar5.TabIndex = 6;
this.trackBar5.ValueChanged += new System.EventHandler(this.trackBar5_ValueChanged);
//
// SelectAll
// label1
//
this.SelectAll.AutoSize = true;
this.SelectAll.Location = new System.Drawing.Point(12, 127);
this.SelectAll.Name = "SelectAll";
this.SelectAll.Size = new System.Drawing.Size(69, 17);
this.SelectAll.TabIndex = 7;
this.SelectAll.Text = "Select all";
this.SelectAll.UseVisualStyleBackColor = true;
this.SelectAll.Click += new System.EventHandler(this.SelectAll_Click);
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(122, 12);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(50, 13);
this.label1.TabIndex = 7;
this.label1.Text = "Square 1";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(122, 60);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(50, 13);
this.label2.TabIndex = 8;
this.label2.Text = "Square 2";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(122, 108);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(45, 13);
this.label3.TabIndex = 9;
this.label3.Text = "Triangle";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(122, 156);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(34, 13);
this.label4.TabIndex = 10;
this.label4.Text = "Noise";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(122, 204);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(31, 13);
this.label5.TabIndex = 11;
this.label5.Text = "DMC";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(122, 25);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(13, 13);
this.label6.TabIndex = 12;
this.label6.Text = "0";
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(122, 73);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(13, 13);
this.label7.TabIndex = 13;
this.label7.Text = "0";
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(122, 121);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(13, 13);
this.label8.TabIndex = 14;
this.label8.Text = "0";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(122, 169);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(13, 13);
this.label9.TabIndex = 15;
this.label9.Text = "0";
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(122, 217);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(13, 13);
this.label10.TabIndex = 16;
this.label10.Text = "0";
//
// NESSoundConfig
//
@ -128,19 +211,33 @@
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(220, 193);
this.Controls.Add(this.SelectAll);
this.Controls.Add(this.DMC);
this.Controls.Add(this.Noise);
this.Controls.Add(this.Square2);
this.Controls.Add(this.Triangle);
this.Controls.Add(this.Square1);
this.ClientSize = new System.Drawing.Size(209, 297);
this.Controls.Add(this.label10);
this.Controls.Add(this.label9);
this.Controls.Add(this.label8);
this.Controls.Add(this.label7);
this.Controls.Add(this.label6);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.trackBar5);
this.Controls.Add(this.trackBar4);
this.Controls.Add(this.trackBar3);
this.Controls.Add(this.trackBar2);
this.Controls.Add(this.trackBar1);
this.Controls.Add(this.Cancel);
this.Controls.Add(this.OK);
this.Name = "NESSoundConfig";
this.ShowIcon = false;
this.Text = "NES Sound Channels";
this.Load += new System.EventHandler(this.NESSoundConfig_Load);
((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.trackBar2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.trackBar3)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.trackBar4)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.trackBar5)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@ -150,11 +247,20 @@
private System.Windows.Forms.Button OK;
private System.Windows.Forms.Button Cancel;
private System.Windows.Forms.CheckBox Square1;
private System.Windows.Forms.CheckBox Triangle;
private System.Windows.Forms.CheckBox Noise;
private System.Windows.Forms.CheckBox Square2;
private System.Windows.Forms.CheckBox DMC;
private System.Windows.Forms.CheckBox SelectAll;
private System.Windows.Forms.TrackBar trackBar1;
private System.Windows.Forms.TrackBar trackBar2;
private System.Windows.Forms.TrackBar trackBar3;
private System.Windows.Forms.TrackBar trackBar4;
private System.Windows.Forms.TrackBar trackBar5;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.Label label10;
}
}

View File

@ -8,24 +8,29 @@ namespace BizHawk.MultiClient
public NESSoundConfig()
{
InitializeComponent();
trackBar1.Maximum = Config.NESSquare1Max;
trackBar2.Maximum = Config.NESSquare2Max;
trackBar3.Maximum = Config.NESTriangleMax;
trackBar4.Maximum = Config.NESNoiseMax;
trackBar5.Maximum = Config.NESDMCMax;
}
private void NESSoundConfig_Load(object sender, EventArgs e)
{
Square1.Checked = Global.Config.NESEnableSquare1;
Square2.Checked = Global.Config.NESEnableSquare2;
Triangle.Checked = Global.Config.NESEnableTriangle;
Noise.Checked = Global.Config.NESEnableNoise;
DMC.Checked = Global.Config.NESEnableDMC;
trackBar1.Value = Global.Config.NESSquare1;
trackBar2.Value = Global.Config.NESSquare2;
trackBar3.Value = Global.Config.NESTriangle;
trackBar4.Value = Global.Config.NESNoise;
trackBar5.Value = Global.Config.NESDMC;
}
private void OK_Click(object sender, EventArgs e)
{
Global.Config.NESEnableSquare1 = Square1.Checked;
Global.Config.NESEnableSquare2 = Square2.Checked;
Global.Config.NESEnableTriangle = Triangle.Checked;
Global.Config.NESEnableNoise = Noise.Checked;
Global.Config.NESEnableDMC = DMC.Checked;
Global.Config.NESSquare1 = trackBar1.Value;
Global.Config.NESSquare2 = trackBar2.Value;
Global.Config.NESTriangle = trackBar3.Value;
Global.Config.NESNoise = trackBar4.Value;
Global.Config.NESDMC = trackBar5.Value;
Global.MainForm.SetNESSoundChannels();
Close();
}
@ -37,6 +42,7 @@ namespace BizHawk.MultiClient
private void SelectAll_Click(object sender, EventArgs e)
{
/*
if (SelectAll.Checked)
{
Square1.Checked = true;
@ -53,6 +59,32 @@ namespace BizHawk.MultiClient
Noise.Checked = false;
DMC.Checked = false;
}
*/
}
private void trackBar1_ValueChanged(object sender, EventArgs e)
{
label6.Text = trackBar1.Value.ToString();
}
private void trackBar2_ValueChanged(object sender, EventArgs e)
{
label7.Text = trackBar2.Value.ToString();
}
private void trackBar3_ValueChanged(object sender, EventArgs e)
{
label8.Text = trackBar3.Value.ToString();
}
private void trackBar4_ValueChanged(object sender, EventArgs e)
{
label9.Text = trackBar4.Value.ToString();
}
private void trackBar5_ValueChanged(object sender, EventArgs e)
{
label10.Text = trackBar5.Value.ToString();
}
}
}