From b932593c9e68337bfcbd43f8b69f5a4cc8d04ff8 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Mon, 5 Sep 2005 21:03:43 +0000 Subject: 16-bit sound Subversion-branch: /trunk/chocolate-doom Subversion-revision: 74 --- src/i_sound.c | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/i_sound.c b/src/i_sound.c index 4cd1fcb0..e97ccc29 100644 --- a/src/i_sound.c +++ b/src/i_sound.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: i_sound.c 73 2005-09-05 20:32:18Z fraggle $ +// $Id: i_sound.c 74 2005-09-05 21:03:43Z fraggle $ // // Copyright(C) 1993-1996 Id Software, Inc. // Copyright(C) 2005 Simon Howard @@ -22,6 +22,9 @@ // 02111-1307, USA. // // $Log$ +// Revision 1.12 2005/09/05 21:03:43 fraggle +// 16-bit sound +// // Revision 1.11 2005/09/05 20:32:18 fraggle // Use the system-nonspecific sound code to assign the channel number used // by SDL. Remove handle tagging stuff. @@ -67,7 +70,7 @@ //----------------------------------------------------------------------------- static const char -rcsid[] = "$Id: i_sound.c 73 2005-09-05 20:32:18Z fraggle $"; +rcsid[] = "$Id: i_sound.c 74 2005-09-05 21:03:43Z fraggle $"; #include #include @@ -97,25 +100,38 @@ static byte *expand_sound_data(byte *data, int samplerate, int length) if (samplerate == 11025) { - // need to expand to 2 channels, and expand 11025->22050 + // need to expand to 2 channels, 11025->22050 and 8->16 bit - result = Z_Malloc(length * 4, PU_STATIC, NULL); + result = Z_Malloc(length * 8, PU_STATIC, NULL); for (i=0; i> 8) & 0xff; } } else if (samplerate == 22050) { // need to expand to 2 channels (sample rate is already correct) - result = Z_Malloc(length * 2, PU_STATIC, NULL); + result = Z_Malloc(length * 4, PU_STATIC, NULL); for (i=0; i> 8) & 0xff; } } else @@ -145,7 +161,7 @@ static Mix_Chunk *getsfx(int sound) sound_chunks[sound].allocated = 1; sound_chunks[sound].abuf = expand_sound_data(data + 8, samplerate, length); - sound_chunks[sound].alen = (length * 2) * (22050 / samplerate); + sound_chunks[sound].alen = (length * 4) * (22050 / samplerate); sound_chunks[sound].volume = 64; } @@ -321,7 +337,7 @@ I_InitSound() return; } - if (Mix_OpenAudio(22050, AUDIO_U8, 2, 1024) < 0) + if (Mix_OpenAudio(22050, AUDIO_S16LSB, 2, 1024) < 0) { fprintf(stderr, "Error initialising SDL_mixer: %s\n", SDL_GetError()); } -- cgit v1.2.3