summaryrefslogtreecommitdiff
path: root/src/i_sdlsound.c
diff options
context:
space:
mode:
authorSimon Howard2010-08-07 16:07:00 +0000
committerSimon Howard2010-08-07 16:07:00 +0000
commit5e9a9a52dbebabda79f221caf318dd8fba4b0781 (patch)
treefece713f1731ebdc2e66b19ba4554c7baf8220a1 /src/i_sdlsound.c
parent05cafe91729446ebd28f3fdab2302277c53530d1 (diff)
downloadchocolate-doom-5e9a9a52dbebabda79f221caf318dd8fba4b0781.tar.gz
chocolate-doom-5e9a9a52dbebabda79f221caf318dd8fba4b0781.tar.bz2
chocolate-doom-5e9a9a52dbebabda79f221caf318dd8fba4b0781.zip
Fix sound resampling low pass filter.
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1951
Diffstat (limited to 'src/i_sdlsound.c')
-rw-r--r--src/i_sdlsound.c9
1 files 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 */