aboutsummaryrefslogtreecommitdiff
path: root/engines/simon
diff options
context:
space:
mode:
authorTravis Howell2006-04-22 03:53:14 +0000
committerTravis Howell2006-04-22 03:53:14 +0000
commit77497d5ed95d8f7015fb4caffa396a381a3c8869 (patch)
treed58587a5e243220dbfd8909553a1b6552ef22ba0 /engines/simon
parentff6028b00bca2a01ed41f8f8ed5ee5c86f8f1410 (diff)
downloadscummvm-rg350-77497d5ed95d8f7015fb4caffa396a381a3c8869.tar.gz
scummvm-rg350-77497d5ed95d8f7015fb4caffa396a381a3c8869.tar.bz2
scummvm-rg350-77497d5ed95d8f7015fb4caffa396a381a3c8869.zip
Enable MS ADPCM WAV format decoder for all sound in Macintosh version of FF and cleanup
svn-id: r22081
Diffstat (limited to 'engines/simon')
-rw-r--r--engines/simon/sound.cpp42
-rw-r--r--engines/simon/sound.h2
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);