ref: b0519667da8edcea1592a0ba7b0dfa4b4709e034
parent: 6a5d123fc662bcdbc08d973e3b8b79a95f24fa51
author: Simon Howard <[email protected]>
date: Sun Mar 6 15:59:51 EST 2011
Discard very short sound effects and strip lead-in / lead-out samples that apparently aren't played by Vanilla Doom (thanks Quasar). Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2291
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,10 @@
1.6.0 (2011-??-??):
+ Compatibility:
+ * Very short sound effects are not played, to better emulate the
+ behavior of DMX in Vanilla Doom (thanks to Quasar for help in
+ investigating this).
+
Bugs fixed:
* Menu navigation when using joystick/joypad (thanks Alexandre
Xavier).
--- a/src/i_sdlsound.c
+++ b/src/i_sdlsound.c
@@ -359,7 +359,13 @@
// greater than the length of the lump itself, this is an invalid
// sound lump.
- if (*length > lumplen - 8)
+ // We also discard sound lumps that are less than 49 samples long,
+ // as this is how DMX behaves - although the actual cut-off length
+ // seems to vary slightly depending on the sample rate. This needs
+ // further investigation to better understand the correct
+ // behavior.
+
+ if (*length > lumplen - 8 || *length <= 48)
{
W_ReleaseLumpNum(*lumpnum);
return false;
@@ -367,6 +373,12 @@
// Prune header
*data_ref += 8;
+
+ // The DMX sound library seems to skip the first 16 and last 16
+ // bytes of the lump - reason unknown.
+
+ *data_ref += 16;
+ *length -= 32;
return true;
}