DCFilter: add a "push" mode more suited to being placed between a resampler and a metaspu
Gambatte: change the order of output from "GB => resampler => metaspu => DCFilter" to "GB => resampler => DCFilter => metaspu". This doesn't change anything under most circumstances, except when playing the emulator in slow motion (for instance, 50% throttle). There, the metaspu sometimes adds silence to the output, which isn't actually silence if it has a different DC offset than the audio it's being mixed with. Well, 50% throttle sound output will always suck anyway...
This commit is contained in:
parent
486d621657
commit
b6e4d9996e
|
@ -585,13 +585,15 @@ namespace BizHawk.Emulation.Consoles.GB
|
||||||
int soundbuffcontains = 0;
|
int soundbuffcontains = 0;
|
||||||
|
|
||||||
Sound.Utilities.SpeexResampler resampler;
|
Sound.Utilities.SpeexResampler resampler;
|
||||||
ISoundProvider metaspu;
|
Sound.MetaspuSoundProvider metaspu;
|
||||||
|
|
||||||
|
Sound.Utilities.DCFilter dcfilter;
|
||||||
|
|
||||||
void InitSound()
|
void InitSound()
|
||||||
{
|
{
|
||||||
var metaspu = new Sound.MetaspuSoundProvider(Sound.ESynchMethod.ESynchMethod_V);
|
dcfilter = new Sound.Utilities.DCFilter();
|
||||||
resampler = new Sound.Utilities.SpeexResampler(2, 2097152, 44100, 2097152, 44100, metaspu.buffer.enqueue_samples);
|
metaspu = new Sound.MetaspuSoundProvider(Sound.ESynchMethod.ESynchMethod_V);
|
||||||
this.metaspu = new Sound.Utilities.DCFilter(metaspu);// metaspu;
|
resampler = new Sound.Utilities.SpeexResampler(2, 2097152, 44100, 2097152, 44100, LoadThroughSamples);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisposeSound()
|
void DisposeSound()
|
||||||
|
@ -600,6 +602,12 @@ namespace BizHawk.Emulation.Consoles.GB
|
||||||
resampler = null;
|
resampler = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LoadThroughSamples(short[] buff, int length)
|
||||||
|
{
|
||||||
|
dcfilter.PushThroughSamples(buff, length * 2);
|
||||||
|
metaspu.buffer.enqueue_samples(buff, length);
|
||||||
|
}
|
||||||
|
|
||||||
public void GetSamples(short[] samples)
|
public void GetSamples(short[] samples)
|
||||||
{
|
{
|
||||||
if (soundbuffcontains > 0)
|
if (soundbuffcontains > 0)
|
||||||
|
|
|
@ -25,8 +25,12 @@ namespace BizHawk.Emulation.Sound.Utilities
|
||||||
Queue<short> buffer;
|
Queue<short> buffer;
|
||||||
|
|
||||||
const int depth = 65536;
|
const int depth = 65536;
|
||||||
|
|
||||||
public DCFilter(ISoundProvider input)
|
/// <summary>
|
||||||
|
/// if input == null, run in detatched push mode
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
public DCFilter(ISoundProvider input = null)
|
||||||
{
|
{
|
||||||
this.input = input;
|
this.input = input;
|
||||||
this.buffer = new Queue<short>(depth * 2);
|
this.buffer = new Queue<short>(depth * 2);
|
||||||
|
@ -45,13 +49,13 @@ namespace BizHawk.Emulation.Sound.Utilities
|
||||||
input = null;
|
input = null;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GetSamples(short[] samples)
|
/// <summary>
|
||||||
|
/// pass a set of samples through the filter. should not be mixed with pull (ISoundProvider) mode
|
||||||
|
/// </summary>
|
||||||
|
public void PushThroughSamples(short[] samples, int length)
|
||||||
{
|
{
|
||||||
|
for (int i = 0; i < length; i += 2)
|
||||||
input.GetSamples(samples);
|
|
||||||
|
|
||||||
for (int i = 0; i < samples.Length; i += 2)
|
|
||||||
{
|
{
|
||||||
sumL -= buffer.Dequeue();
|
sumL -= buffer.Dequeue();
|
||||||
sumR -= buffer.Dequeue();
|
sumR -= buffer.Dequeue();
|
||||||
|
@ -80,6 +84,12 @@ namespace BizHawk.Emulation.Sound.Utilities
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void GetSamples(short[] samples)
|
||||||
|
{
|
||||||
|
input.GetSamples(samples);
|
||||||
|
PushThroughSamples(samples, samples.Length);
|
||||||
|
}
|
||||||
|
|
||||||
public void DiscardSamples()
|
public void DiscardSamples()
|
||||||
{
|
{
|
||||||
input.DiscardSamples();
|
input.DiscardSamples();
|
||||||
|
|
Loading…
Reference in New Issue