diff --git a/BizHawk.Emulation/Consoles/Atari/2600/Atari2600.Core.cs b/BizHawk.Emulation/Consoles/Atari/2600/Atari2600.Core.cs index ee0b4567e7..9efe7fe4d9 100644 --- a/BizHawk.Emulation/Consoles/Atari/2600/Atari2600.Core.cs +++ b/BizHawk.Emulation/Consoles/Atari/2600/Atari2600.Core.cs @@ -13,6 +13,7 @@ namespace BizHawk public MOS6502X cpu; public M6532 m6532; public TIA tia; + public Emulation.Sound.Utilities.DCFilter dcfilter; public byte[] ram = new byte[128]; public MapperBase mapper; @@ -142,6 +143,8 @@ namespace BizHawk // Setup TIA //tia = new TIA(this, frameBuffer); tia = new TIA(this); + // dcfilter coefficent is from real observed hardware behavior: a latched "1" will fully decay by ~170 or so tia sound cycles + dcfilter = new Emulation.Sound.Utilities.DCFilter(tia, 256); // Setup 6532 m6532 = new M6532(this); diff --git a/BizHawk.Emulation/Consoles/Atari/2600/Atari2600.cs b/BizHawk.Emulation/Consoles/Atari/2600/Atari2600.cs index 55dace3c72..83596930e9 100644 --- a/BizHawk.Emulation/Consoles/Atari/2600/Atari2600.cs +++ b/BizHawk.Emulation/Consoles/Atari/2600/Atari2600.cs @@ -12,7 +12,7 @@ namespace BizHawk public CoreInputComm CoreInputComm { get; set; } public CoreOutputComm CoreOutputComm { get; private set; } public IVideoProvider VideoProvider { get { return tia; } } - public ISoundProvider SoundProvider { get { return tia; } } + public ISoundProvider SoundProvider { get { return dcfilter; } } public Atari2600(GameInfo game, byte[] rom) { diff --git a/BizHawk.Emulation/Sound/Utilities/DCFilter.cs b/BizHawk.Emulation/Sound/Utilities/DCFilter.cs index b910e1c1ec..079bfe96e6 100644 --- a/BizHawk.Emulation/Sound/Utilities/DCFilter.cs +++ b/BizHawk.Emulation/Sound/Utilities/DCFilter.cs @@ -24,15 +24,16 @@ namespace BizHawk.Emulation.Sound.Utilities Queue buffer; - const int depth = 65536; + int depth; /// /// if input == null, run in detatched push mode /// /// - public DCFilter(ISoundProvider input = null) + public DCFilter(ISoundProvider input = null, int filterwidth = 65536) { this.input = input; + this.depth = filterwidth; this.buffer = new Queue(depth * 2); for (int i = 0; i < depth * 2; i++) buffer.Enqueue(0); @@ -65,8 +66,8 @@ namespace BizHawk.Emulation.Sound.Utilities sumR += R; buffer.Enqueue(L); buffer.Enqueue(R); - int bigL = L - (sumL >> 16); // / depth; - int bigR = R - (sumR >> 16); // / depth; + int bigL = L - sumL / depth; + int bigR = R - sumR / depth; // check for clipping if (bigL > 32767) samples[i] = 32767;