commit 5e9a9a52dbebabda79f221caf318dd8fba4b0781
Author: Simon Howard <fraggle@gmail.com>
AuthorDate: Sat Aug 7 16:07:00 2010 +0000
Commit: Simon Howard <fraggle@gmail.com>
CommitDate: Sat Aug 7 16:07:00 2010 +0000
Fix sound resampling low pass filter.
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 1951
---
src/i_sdlsound.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/i_sdlsound.c b/src/i_sdlsound.c
index d51345c7..ff191202 100644
--- a/src/i_sdlsound.c
+++ b/src/i_sdlsound.c
@@ -244,12 +244,15 @@ static void ExpandSoundData_SDL(byte *data,
// (maximum frequency, by nyquist)
dt = 1.0f / mixer_freq;
- rc = 1.0f / (3.14f * samplerate);
+ rc = 1.0f / (2 * 3.14f * samplerate);
alpha = dt / (rc + dt);
- for (i=1; i<expanded_length; ++i)
+ // Both channels are processed in parallel, hence [i-2]:
+
+ for (i=2; i<expanded_length * 2; ++i)
{
- expanded[i] = (Sint16) (alpha * expanded[i] + (1 - alpha) * expanded[i-1]);
+ expanded[i] = (Sint16) (alpha * expanded[i]
+ + (1 - alpha) * expanded[i-2]);
}
}
#endif /* #ifdef LOW_PASS_FILTER */