diff --git a/BizHawk.Emulation/Sound/Utilities/BufferedAsync.cs b/BizHawk.Emulation/Sound/Utilities/BufferedAsync.cs index c77c9d2578..4da339a014 100644 --- a/BizHawk.Emulation/Sound/Utilities/BufferedAsync.cs +++ b/BizHawk.Emulation/Sound/Utilities/BufferedAsync.cs @@ -34,10 +34,20 @@ namespace BizHawk.Emulation.Sound Queue buffer = new Queue(4096); - const int SamplesInOneFrame = 1470; - const int TargetExtraSamples = 882; + int SamplesInOneFrame = 1470; + int TargetExtraSamples = 882; const int MaxExcessSamples = 4096; + /// + /// recalculates some internal parameters based on the IEmulator's framerate + /// + public void RecalculateMagic(double framerate) + { + // ceiling instead of floor here is very important (magic) + SamplesInOneFrame = (int)System.Math.Ceiling((88200.0 / framerate)); + //TargetExtraSamples = ;// complete guess + } + public void DiscardSamples() { if(BaseSoundProvider != null) diff --git a/BizHawk.MultiClient/Sound.cs b/BizHawk.MultiClient/Sound.cs index 006aa24f77..eba5f9d381 100644 --- a/BizHawk.MultiClient/Sound.cs +++ b/BizHawk.MultiClient/Sound.cs @@ -109,6 +109,7 @@ namespace BizHawk.MultiClient syncsoundProvider = null; asyncsoundProvider = source; semisync.BaseSoundProvider = source; + semisync.RecalculateMagic(Global.CoreComm.VsyncRate); } static int circularDist(int from, int to, int size)