From 3378ea80013cced55e0c65eb253fcdaa8c42e5d0 Mon Sep 17 00:00:00 2001 From: goyuken Date: Mon, 22 Oct 2012 17:04:37 +0000 Subject: [PATCH] fds audio: clip. intro to Metroid now sounds passable --- .../Consoles/Nintendo/NES/FDS/FDSAudio.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/FDS/FDSAudio.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/FDS/FDSAudio.cs index e1b324ca64..521af4fee1 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/NES/FDS/FDSAudio.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/NES/FDS/FDSAudio.cs @@ -266,15 +266,21 @@ namespace BizHawk.Emulation.Consoles.Nintendo { for (int i = 0; i < samples.Length; i += 2) { + // worst imaginable resampling int pos = i * samplebuffpos / samples.Length; + int samp = samplebuff[pos] * 20 - 20160; + samp += samples[i]; + if (samp > 32767) + samples[i] = 32767; + else if (samp < -32768) + samples[i] = -32768; + else + samples[i] = (short)samp; - short samp = (short)(samplebuff[pos] * 20 - 20160); - // nothing for clipping, and the worst imaginable resampling - samples[i] += samp; - samples[i + 1] += samp; - + // NES audio is mono, so this should be identical anyway + samples[i + 1] = samples[i]; } - Console.WriteLine("##{0}##", samplebuffpos); + //Console.WriteLine("##{0}##", samplebuffpos); samplebuffpos = 0; } }