[Scummvm-cvs-logs] CVS: scummvm/scumm sound.cpp,1.479.2.2,1.479.2.3

Eugene Sandulenko sev at users.sourceforge.net
Thu Oct 20 19:26:08 CEST 2005


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2503/scumm

Modified Files:
      Tag: branch-0-8-0
	sound.cpp 
Log Message:
Backport IMA ADPCM fixes. This fixes bunch of latter HE games.


Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.cpp,v
retrieving revision 1.479.2.2
retrieving revision 1.479.2.3
diff -u -d -r1.479.2.2 -r1.479.2.3
--- sound.cpp	20 Oct 2005 14:11:00 -0000	1.479.2.2
+++ sound.cpp	21 Oct 2005 02:25:20 -0000	1.479.2.3
@@ -33,6 +33,7 @@
 #include "common/timer.h"
 #include "common/util.h"
 
+#include "sound/adpcm.h"
 #include "sound/audiocd.h"
 #include "sound/flac.h"
 #include "sound/mididrv.h"
@@ -306,16 +307,26 @@
 	}
 	// Support for later Backyard sports games sounds
 	else if (READ_UINT32(ptr) == MKID('RIFF')) {
-		size = READ_BE_UINT32(ptr + 4);
+		uint16 type;
+		int blockAlign;
+		size = READ_LE_UINT32(ptr + 4);
 		Common::MemoryReadStream stream(ptr, size);
 
-		if (!loadWAVFromStream(stream, size, rate, flags)) {
+		if (!loadWAVFromStream(stream, size, rate, flags, &type, &blockAlign)) {
 			error("playSound: Not a valid WAV file");
 		}
 
-		// Allocate a sound buffer, copy the data into it, and play
-		sound = (char *)malloc(size);
-		memcpy(sound, ptr + stream.pos(), size);
+		if (type == 17) {
+			AudioStream *voxStream = new ADPCMInputStream(&stream, size, kADPCMIma, (flags & Audio::Mixer::FLAG_STEREO) ? 2 : 1, blockAlign);
+
+			sound = (char *)malloc(size * 4);
+			size = voxStream->readBuffer((int16*)sound, size * 2);
+			size *= 2; // 16bits.
+		} else {
+			// Allocate a sound buffer, copy the data into it, and play
+			sound = (char *)malloc(size);
+			memcpy(sound, ptr + stream.pos(), size);
+		}
 		_vm->_mixer->playRaw(&_heSoundChannels[heChannel], sound, size, rate, flags, soundID);
 	}
 	// Support for Putt-Putt sounds - very hackish, too 8-)





More information about the Scummvm-git-logs mailing list