7800: clean up some sound-related stuff
This commit is contained in:
parent
0636bda89d
commit
faceb7e18d
|
@ -32,6 +32,7 @@ namespace BizHawk
|
||||||
}
|
}
|
||||||
|
|
||||||
avProvider.FillFrameBuffer();
|
avProvider.FillFrameBuffer();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO */
|
/* TODO */
|
||||||
|
@ -251,13 +252,19 @@ namespace BizHawk
|
||||||
BufferHeight = framebuffer.Scanlines;
|
BufferHeight = framebuffer.Scanlines;
|
||||||
vidbuffer = new int[BufferWidth * BufferHeight];
|
vidbuffer = new int[BufferWidth * BufferHeight];
|
||||||
|
|
||||||
uint samplerate = (uint)m.SoundSampleFrequency;
|
uint newsamplerate = (uint)m.SoundSampleFrequency;
|
||||||
if (resampler != null)
|
if (newsamplerate != samplerate)
|
||||||
resampler.Dispose();
|
{
|
||||||
resampler = new Emulation.Sound.Utilities.SpeexResampler(3, samplerate, 44100, samplerate, 44100, null, null);
|
// really shouldn't happen, but if it does, we're ready
|
||||||
dcfilter = Emulation.Sound.Utilities.DCFilter.DetatchedMode(256);
|
if (resampler != null)
|
||||||
|
resampler.Dispose();
|
||||||
|
resampler = new Emulation.Sound.Utilities.SpeexResampler(3, newsamplerate, 44100, newsamplerate, 44100, null, null);
|
||||||
|
samplerate = newsamplerate;
|
||||||
|
dcfilter = Emulation.Sound.Utilities.DCFilter.DetatchedMode(256);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint samplerate;
|
||||||
int[] vidbuffer;
|
int[] vidbuffer;
|
||||||
Emulation.Sound.Utilities.SpeexResampler resampler;
|
Emulation.Sound.Utilities.SpeexResampler resampler;
|
||||||
Emulation.Sound.Utilities.DCFilter dcfilter;
|
Emulation.Sound.Utilities.DCFilter dcfilter;
|
||||||
|
@ -304,7 +311,9 @@ namespace BizHawk
|
||||||
byte* src = (byte*)src_;
|
byte* src = (byte*)src_;
|
||||||
for (int i = 0; i < nsampin; i++)
|
for (int i = 0; i < nsampin; i++)
|
||||||
{
|
{
|
||||||
short s = (short)(src[i] * 200 - 25500);
|
// the buffer values don't really get very large at all,
|
||||||
|
// so this doesn't overflow
|
||||||
|
short s = (short)(src[i] * 200);
|
||||||
resampler.EnqueueSample(s, s);
|
resampler.EnqueueSample(s, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,7 +325,8 @@ namespace BizHawk
|
||||||
|
|
||||||
public void DiscardSamples()
|
public void DiscardSamples()
|
||||||
{
|
{
|
||||||
resampler.DiscardSamples();
|
if (resampler != null)
|
||||||
|
resampler.DiscardSamples();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
|
Loading…
Reference in New Issue