ref: 7e3ee003d57cc4ca48f760066c6be19ba3002bc9
parent: 8e611a519819a2a64d6562735d250abaf1b19ce5
author: Simon Howard <[email protected]>
date: Sun Jan 22 20:40:24 EST 2006
Fix bug when expanding large sound effects with odd sample rates Subversion-branch: /trunk/chocolate-doom Subversion-revision: 338
--- 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 @@
{
byte *expanded = (byte *) destination->abuf;
int expanded_length;
+ int expand_ratio;
int i;
if (samplerate == 11025)
@@ -232,6 +236,7 @@
// 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)
{
@@ -238,7 +243,7 @@
Uint16 sample;
int src;
- src = (i * length) / expanded_length;
+ src = (i * expand_ratio) >> 8;
sample = data[src] | (data[src] << 8);
sample -= 32768;