diff options
author | Simon Howard | 2006-01-23 01:40:24 +0000 |
---|---|---|
committer | Simon Howard | 2006-01-23 01:40:24 +0000 |
commit | 7e3ee003d57cc4ca48f760066c6be19ba3002bc9 (patch) | |
tree | 61392acb685e5b07b6115f5d59ee24d13756d00b | |
parent | 8e611a519819a2a64d6562735d250abaf1b19ce5 (diff) | |
download | chocolate-doom-7e3ee003d57cc4ca48f760066c6be19ba3002bc9.tar.gz chocolate-doom-7e3ee003d57cc4ca48f760066c6be19ba3002bc9.tar.bz2 chocolate-doom-7e3ee003d57cc4ca48f760066c6be19ba3002bc9.zip |
Fix bug when expanding large sound effects with odd sample rates
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 338
-rw-r--r-- | src/i_sound.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/i_sound.c b/src/i_sound.c index 37e3ac9e..0935c95c 100644 --- a/src/i_sound.c +++ b/src/i_sound.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: i_sound.c 318 2006-01-22 21:20:20Z fraggle $ +// $Id: i_sound.c 338 2006-01-23 01:40:24Z fraggle $ // // Copyright(C) 1993-1996 Id Software, Inc. // Copyright(C) 2005 Simon Howard @@ -22,6 +22,9 @@ // 02111-1307, USA. // // $Log$ +// Revision 1.27 2006/01/23 01:40:24 fraggle +// Fix bug when expanding large sound effects with odd sample rates +// // Revision 1.26 2006/01/22 21:20:20 fraggle // Dehacked string replacements for sound and music lump names // @@ -125,7 +128,7 @@ //----------------------------------------------------------------------------- static const char -rcsid[] = "$Id: i_sound.c 318 2006-01-22 21:20:20Z fraggle $"; +rcsid[] = "$Id: i_sound.c 338 2006-01-23 01:40:24Z fraggle $"; #include <stdio.h> #include <stdlib.h> @@ -191,6 +194,7 @@ static void ExpandSoundData(byte *data, int samplerate, int length, { byte *expanded = (byte *) destination->abuf; int expanded_length; + int expand_ratio; int i; if (samplerate == 11025) @@ -232,13 +236,14 @@ static void ExpandSoundData(byte *data, int samplerate, int length, // number of samples in the converted sound expanded_length = (length * 22050) / samplerate; + expand_ratio = (length << 8) / expanded_length; for (i=0; i<expanded_length; ++i) { Uint16 sample; int src; - src = (i * length) / expanded_length; + src = (i * expand_ratio) >> 8; sample = data[src] | (data[src] << 8); sample -= 32768; |