diff options
| -rw-r--r-- | engines/simon/sound.cpp | 42 | ||||
| -rw-r--r-- | engines/simon/sound.h | 2 | 
2 files changed, 22 insertions, 22 deletions
diff --git a/engines/simon/sound.cpp b/engines/simon/sound.cpp index 43be448187..b9a2bf6539 100644 --- a/engines/simon/sound.cpp +++ b/engines/simon/sound.cpp @@ -25,6 +25,8 @@  #include "simon/simon.h"  #include "simon/sound.h" +#include "sound/adpcm.h" +#include "sound/audiostream.h"  #include "sound/flac.h"  #include "sound/mp3.h"  #include "sound/voc.h" @@ -578,39 +580,37 @@ void Sound::playSfx5Data(byte *soundData, uint sound, uint pan, uint vol) {  	playSoundData(&_sfx5Handle, soundData, sound, pan, vol, true);  } +void Sound::playVoiceData(byte *soundData, uint sound) { +	_mixer->stopHandle(_voiceHandle); +	playSoundData(&_voiceHandle, soundData, sound); +} +  void Sound::playSoundData(Audio::SoundHandle *handle, byte *soundData, uint sound, uint pan, uint vol, bool loop) { -	byte flags; -	int rate; +	byte *buffer, flags; +	uint16 compType; +	int blockAlign, rate;  	int size = READ_LE_UINT32(soundData + 4);  	Common::MemoryReadStream stream(soundData, size); -	if (!loadWAVFromStream(stream, size, rate, flags)) { +	if (!loadWAVFromStream(stream, size, rate, flags, &compType, &blockAlign)) {  		error("playSoundData: Not a valid WAV data");  	}  	if (loop == true)  		flags |= Audio::Mixer::FLAG_LOOP; -	byte *buffer = (byte *)malloc(size); -	memcpy(buffer, soundData + stream.pos(), size); -	_mixer->playRaw(handle, buffer, size, rate, flags | Audio::Mixer::FLAG_AUTOFREE); -} - -void Sound::playVoiceData(byte *soundData, uint sound) { -	byte flags; -	int rate; - -	int size = READ_LE_UINT32(soundData + 4); -	Common::MemoryReadStream stream(soundData, size); -	if (!loadWAVFromStream(stream, size, rate, flags)) { -		error("playSoundData: Not a valid WAV data"); +	if (compType == 2) { +		AudioStream *sndStream = makeADPCMStream(&stream, size, kADPCMMS, rate, (flags & Audio::Mixer::FLAG_STEREO) ? 2 : 1, blockAlign); +		buffer = (byte *)malloc(size * 4); +		size = sndStream->readBuffer((int16*)buffer, size * 2); +		size *= 2; // 16bits. +		delete sndStream; +	} else { +		buffer = (byte *)malloc(size); +		memcpy(buffer, soundData + stream.pos(), size);  	} -	byte *buffer = (byte *)malloc(size); -	memcpy(buffer, soundData + stream.pos(), size); - -	_mixer->stopHandle(_voiceHandle); -	_mixer->playRaw(&_voiceHandle, buffer, size, rate, flags); +	_mixer->playRaw(handle, buffer, size, rate, flags | Audio::Mixer::FLAG_AUTOFREE);  }  void Sound::stopSfx5() { diff --git a/engines/simon/sound.h b/engines/simon/sound.h index 093f36c3f1..350f30273d 100644 --- a/engines/simon/sound.h +++ b/engines/simon/sound.h @@ -76,7 +76,7 @@ public:  	void playAmbientData(byte *soundData, uint sound, uint pan, uint vol);  	void playSfxData(byte *soundData, uint sound, uint pan, uint vol);  	void playSfx5Data(byte *soundData, uint sound, uint pan, uint vol); -	void playSoundData(Audio::SoundHandle *handle, byte *soundData, uint sound, uint pan, uint vol, bool loop); +	void playSoundData(Audio::SoundHandle *handle, byte *soundData, uint sound, uint pan = 0, uint vol = 0, bool loop = false);  	void playVoiceData(byte *soundData, uint sound);  	void switchVoiceFile(const GameSpecificSettings *gss, uint disc);  | 
