Temporary fix for N64 sound problems with new sound provider.
This commit is contained in:
parent
5026d39da1
commit
6a81746636
|
@ -37,6 +37,10 @@ namespace BizHawk.Client.EmuHawk
|
||||||
private Queue<int> _outputCountHistory = new Queue<int>();
|
private Queue<int> _outputCountHistory = new Queue<int>();
|
||||||
private Queue<bool> _hardCorrectionHistory = new Queue<bool>();
|
private Queue<bool> _hardCorrectionHistory = new Queue<bool>();
|
||||||
|
|
||||||
|
private bool _disableFramerateCompensation;
|
||||||
|
private double _lastSamplesPerFrame;
|
||||||
|
private int _lastBaseProviderSampleCount;
|
||||||
|
|
||||||
private short[] _resampleBuffer = new short[0];
|
private short[] _resampleBuffer = new short[0];
|
||||||
private double _resampleLengthRoundingError;
|
private double _resampleLengthRoundingError;
|
||||||
|
|
||||||
|
@ -52,6 +56,9 @@ namespace BizHawk.Client.EmuHawk
|
||||||
_extraCountHistory.Clear();
|
_extraCountHistory.Clear();
|
||||||
_outputCountHistory.Clear();
|
_outputCountHistory.Clear();
|
||||||
_hardCorrectionHistory.Clear();
|
_hardCorrectionHistory.Clear();
|
||||||
|
_disableFramerateCompensation = false;
|
||||||
|
_lastSamplesPerFrame = 0.0;
|
||||||
|
_lastBaseProviderSampleCount = 0;
|
||||||
_resampleBuffer = new short[0];
|
_resampleBuffer = new short[0];
|
||||||
_resampleLengthRoundingError = 0.0;
|
_resampleLengthRoundingError = 0.0;
|
||||||
|
|
||||||
|
@ -122,11 +129,12 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
if (LogDebug)
|
if (LogDebug)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Avg: {0:0.0} ms, Min: {1:0.0} ms, Max: {2:0.0} ms, Scale: {3:0.0000}",
|
Console.WriteLine("Avg: {0:0.0} ms, Min: {1:0.0} ms, Max: {2:0.0} ms, Scale: {3:0.0000} {4}",
|
||||||
_extraCountHistory.Average() * 1000.0 / SampleRate,
|
_extraCountHistory.Average() * 1000.0 / SampleRate,
|
||||||
_extraCountHistory.Min() * 1000.0 / SampleRate,
|
_extraCountHistory.Min() * 1000.0 / SampleRate,
|
||||||
_extraCountHistory.Max() * 1000.0 / SampleRate,
|
_extraCountHistory.Max() * 1000.0 / SampleRate,
|
||||||
scaleFactor);
|
scaleFactor,
|
||||||
|
_disableFramerateCompensation ? "*" : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
return outputSampleCount;
|
return outputSampleCount;
|
||||||
|
@ -139,11 +147,25 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
BaseSoundProvider.GetSamples(out samples, out count);
|
BaseSoundProvider.GetSamples(out samples, out count);
|
||||||
|
|
||||||
if (count != 0)
|
if (SamplesPerFrame != _lastSamplesPerFrame)
|
||||||
{
|
{
|
||||||
scaleFactor *= SamplesPerFrame / count;
|
_disableFramerateCompensation = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (count != 0 && !_disableFramerateCompensation)
|
||||||
|
{
|
||||||
|
if (_lastBaseProviderSampleCount != 0 && Math.Abs(count - _lastBaseProviderSampleCount) > 10)
|
||||||
|
{
|
||||||
|
_disableFramerateCompensation = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
scaleFactor *= SamplesPerFrame / count;
|
||||||
|
|
||||||
|
_lastBaseProviderSampleCount = count;
|
||||||
|
}
|
||||||
|
|
||||||
|
_lastSamplesPerFrame = SamplesPerFrame;
|
||||||
|
|
||||||
double newCountTarget = count * scaleFactor;
|
double newCountTarget = count * scaleFactor;
|
||||||
int newCount = (int)Math.Round(newCountTarget + _resampleLengthRoundingError);
|
int newCount = (int)Math.Round(newCountTarget + _resampleLengthRoundingError);
|
||||||
// Do not resample for one-sample differences. With NTSC @ 59.94 FPS, for example,
|
// Do not resample for one-sample differences. With NTSC @ 59.94 FPS, for example,
|
||||||
|
|
Loading…
Reference in New Issue