gb: add mute sound as a setting. most useful in dual mode.
This commit is contained in:
parent
5349affbc4
commit
0a17fadb8e
|
@ -31,6 +31,7 @@
|
||||||
this.propertyGrid1 = new System.Windows.Forms.PropertyGrid();
|
this.propertyGrid1 = new System.Windows.Forms.PropertyGrid();
|
||||||
this.buttonDefaults = new System.Windows.Forms.Button();
|
this.buttonDefaults = new System.Windows.Forms.Button();
|
||||||
this.buttonPalette = new System.Windows.Forms.Button();
|
this.buttonPalette = new System.Windows.Forms.Button();
|
||||||
|
this.checkBoxMuted = new System.Windows.Forms.CheckBox();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// propertyGrid1
|
// propertyGrid1
|
||||||
|
@ -68,16 +69,30 @@
|
||||||
this.buttonPalette.UseVisualStyleBackColor = true;
|
this.buttonPalette.UseVisualStyleBackColor = true;
|
||||||
this.buttonPalette.Click += new System.EventHandler(this.buttonPalette_Click);
|
this.buttonPalette.Click += new System.EventHandler(this.buttonPalette_Click);
|
||||||
//
|
//
|
||||||
|
// checkBoxMuted
|
||||||
|
//
|
||||||
|
this.checkBoxMuted.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||||
|
this.checkBoxMuted.AutoSize = true;
|
||||||
|
this.checkBoxMuted.Location = new System.Drawing.Point(84, 289);
|
||||||
|
this.checkBoxMuted.Name = "checkBoxMuted";
|
||||||
|
this.checkBoxMuted.Size = new System.Drawing.Size(80, 17);
|
||||||
|
this.checkBoxMuted.TabIndex = 3;
|
||||||
|
this.checkBoxMuted.Text = "Mute Audio";
|
||||||
|
this.checkBoxMuted.UseVisualStyleBackColor = true;
|
||||||
|
this.checkBoxMuted.CheckedChanged += new System.EventHandler(this.checkBoxMuted_CheckedChanged);
|
||||||
|
//
|
||||||
// GBPrefControl
|
// GBPrefControl
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.Controls.Add(this.checkBoxMuted);
|
||||||
this.Controls.Add(this.buttonPalette);
|
this.Controls.Add(this.buttonPalette);
|
||||||
this.Controls.Add(this.buttonDefaults);
|
this.Controls.Add(this.buttonDefaults);
|
||||||
this.Controls.Add(this.propertyGrid1);
|
this.Controls.Add(this.propertyGrid1);
|
||||||
this.Name = "GBPrefControl";
|
this.Name = "GBPrefControl";
|
||||||
this.Size = new System.Drawing.Size(324, 311);
|
this.Size = new System.Drawing.Size(324, 311);
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,5 +101,6 @@
|
||||||
private System.Windows.Forms.PropertyGrid propertyGrid1;
|
private System.Windows.Forms.PropertyGrid propertyGrid1;
|
||||||
private System.Windows.Forms.Button buttonDefaults;
|
private System.Windows.Forms.Button buttonDefaults;
|
||||||
private System.Windows.Forms.Button buttonPalette;
|
private System.Windows.Forms.Button buttonPalette;
|
||||||
|
private System.Windows.Forms.CheckBox checkBoxMuted;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ namespace BizHawk.Client.EmuHawk.config.GB
|
||||||
this.ss = ss ?? new Gameboy.GambatteSyncSettings();
|
this.ss = ss ?? new Gameboy.GambatteSyncSettings();
|
||||||
propertyGrid1.SelectedObject = this.ss;
|
propertyGrid1.SelectedObject = this.ss;
|
||||||
propertyGrid1.Enabled = !Global.MovieSession.Movie.IsActive;
|
propertyGrid1.Enabled = !Global.MovieSession.Movie.IsActive;
|
||||||
|
checkBoxMuted.Checked = this.s.Muted;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GetSettings(out Gameboy.GambatteSettings s, out Gameboy.GambatteSyncSettings ss)
|
public void GetSettings(out Gameboy.GambatteSettings s, out Gameboy.GambatteSyncSettings ss)
|
||||||
|
@ -60,5 +61,10 @@ namespace BizHawk.Client.EmuHawk.config.GB
|
||||||
{
|
{
|
||||||
SyncSettingsChanged = true;
|
SyncSettingsChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkBoxMuted_CheckedChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
s.Muted = (sender as CheckBox).Checked;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -331,7 +331,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
||||||
_cycleCount += (ulong)samplesEmitted;
|
_cycleCount += (ulong)samplesEmitted;
|
||||||
frameOverflow += samplesEmitted;
|
frameOverflow += samplesEmitted;
|
||||||
|
|
||||||
if (rendersound)
|
if (rendersound && !Muted)
|
||||||
{
|
{
|
||||||
ProcessSound((int)samplesEmitted);
|
ProcessSound((int)samplesEmitted);
|
||||||
}
|
}
|
||||||
|
@ -354,13 +354,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
||||||
|
|
||||||
_cycleCount += (ulong)samplesEmitted;
|
_cycleCount += (ulong)samplesEmitted;
|
||||||
frameOverflow = 0;
|
frameOverflow = 0;
|
||||||
if (rendersound)
|
if (rendersound && !Muted)
|
||||||
{
|
{
|
||||||
ProcessSound((int)samplesEmitted);
|
ProcessSound((int)samplesEmitted);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rendersound)
|
if (rendersound && !Muted)
|
||||||
ProcessSoundEnd();
|
ProcessSoundEnd();
|
||||||
|
|
||||||
FrameAdvancePost();
|
FrameAdvancePost();
|
||||||
|
@ -980,6 +980,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
||||||
nsamp = soundoutbuffcontains;
|
nsamp = soundoutbuffcontains;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool Muted { get { return _Settings.Muted; } }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Settings
|
#region Settings
|
||||||
|
@ -1017,6 +1019,10 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
||||||
|
|
||||||
public int[] GBPalette;
|
public int[] GBPalette;
|
||||||
public GBColors.ColorType CGBColors;
|
public GBColors.ColorType CGBColors;
|
||||||
|
/// <summary>
|
||||||
|
/// true to mute all audio
|
||||||
|
/// </summary>
|
||||||
|
public bool Muted;
|
||||||
|
|
||||||
public GambatteSettings()
|
public GambatteSettings()
|
||||||
{
|
{
|
||||||
|
|
|
@ -467,38 +467,58 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
||||||
int LatchL;
|
int LatchL;
|
||||||
int LatchR;
|
int LatchR;
|
||||||
|
|
||||||
void PrepSound()
|
unsafe void PrepSound()
|
||||||
{
|
{
|
||||||
unsafe
|
fixed (short* sl = LeftBuffer, sr = RightBuffer)
|
||||||
{
|
{
|
||||||
fixed (short* sl = LeftBuffer, sr = RightBuffer)
|
for (uint i = 0; i < SampPerFrame * 2; i += 2)
|
||||||
{
|
{
|
||||||
for (uint i = 0; i < SampPerFrame * 2; i += 2)
|
int s = (sl[i] + sl[i + 1]) / 2;
|
||||||
|
if (s != LatchL)
|
||||||
{
|
{
|
||||||
int s = (sl[i] + sl[i + 1]) / 2;
|
blip_left.AddDelta(i, s - LatchL);
|
||||||
if (s != LatchL)
|
LatchL = s;
|
||||||
{
|
}
|
||||||
blip_left.AddDelta(i, s - LatchL);
|
s = (sr[i] + sr[i + 1]) / 2;
|
||||||
LatchL = s;
|
if (s != LatchR)
|
||||||
}
|
{
|
||||||
s = (sr[i] + sr[i + 1]) / 2;
|
blip_right.AddDelta(i, s - LatchR);
|
||||||
if (s != LatchR)
|
LatchR = s;
|
||||||
{
|
|
||||||
blip_right.AddDelta(i, s - LatchR);
|
|
||||||
LatchR = s;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
blip_left.EndFrame(SampPerFrame * 2);
|
blip_left.EndFrame(SampPerFrame * 2);
|
||||||
blip_right.EndFrame(SampPerFrame * 2);
|
blip_right.EndFrame(SampPerFrame * 2);
|
||||||
int count = blip_left.SamplesAvailable();
|
int count = blip_left.SamplesAvailable();
|
||||||
if (count != blip_right.SamplesAvailable())
|
if (count != blip_right.SamplesAvailable())
|
||||||
throw new Exception("Sound problem?");
|
throw new Exception("Sound problem?");
|
||||||
|
|
||||||
|
// calling blip.Clear() causes rounding fractions to be reset,
|
||||||
|
// and if only one channel is muted, in subsequent frames we can be off by a sample or two
|
||||||
|
// not a big deal, but we didn't account for it. so we actually complete the entire
|
||||||
|
// audio read and then stamp it out if muted.
|
||||||
|
|
||||||
blip_left.ReadSamplesLeft(SampleBuffer, count);
|
blip_left.ReadSamplesLeft(SampleBuffer, count);
|
||||||
|
if (L.Muted)
|
||||||
|
{
|
||||||
|
fixed (short* p = SampleBuffer)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < SampleBuffer.Length; i += 2)
|
||||||
|
p[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
blip_right.ReadSamplesRight(SampleBuffer, count);
|
blip_right.ReadSamplesRight(SampleBuffer, count);
|
||||||
|
if (R.Muted)
|
||||||
|
{
|
||||||
|
fixed (short* p = SampleBuffer)
|
||||||
|
{
|
||||||
|
for (int i = 1; i < SampleBuffer.Length; i += 2)
|
||||||
|
p[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
SampleBufferContains = count;
|
SampleBufferContains = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue