libsnes: dumb change to dumb code slightly lessens appearance rate of rice crispies in some situations

This commit is contained in:
goyuken 2012-09-05 01:30:09 +00:00
parent 9b8e54989c
commit fd5494a316
1 changed files with 20 additions and 8 deletions

View File

@ -73,11 +73,11 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
public static extern IntPtr snes_get_memory_data(SNES_MEMORY id);
[DllImport("snes.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int snes_serialize_size();
[return: MarshalAs(UnmanagedType.U1)]
[DllImport("snes.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern bool snes_serialize(IntPtr data, int size);
public static extern int snes_serialize_size();
[return: MarshalAs(UnmanagedType.U1)]
[DllImport("snes.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern bool snes_serialize(IntPtr data, int size);
[return: MarshalAs(UnmanagedType.U1)]
[DllImport("snes.dll", CallingConvention = CallingConvention.Cdecl)]
@ -458,7 +458,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
}
}
// TODO: replace this with something that took more than 5 seconds to write
public void GetSamples(short[] samples)
{
// resample approximately 32k->44k
@ -473,8 +473,20 @@ namespace BizHawk.Emulation.Consoles.Nintendo.SNES
for (i = 0; i < inputcount * 2 && AudioBuffer.Count > 0; i++)
input[i] = AudioBuffer.Dequeue();
for (; i < inputcount * 2; i++)
input[i] = 0;
short lastl, lastr;
if (i >= 2)
{
lastl = input[i - 2];
lastr = input[i - 1];
}
else
lastl = lastr = 0;
for (; i < inputcount * 2; )
{
input[i++] = lastl;
input[i++] = lastr;
}
LinearDownsampler(input, samples);