diff options
author | Max Horn | 2004-01-03 00:55:40 +0000 |
---|---|---|
committer | Max Horn | 2004-01-03 00:55:40 +0000 |
commit | 56eae68e8bafde62e28af1cf5302d52424362684 (patch) | |
tree | 27ee8e2f19ce743f14fd480d622a79c8074f5c98 /scumm | |
parent | 96e2c239c4bc2a6f91d3fb141551eac06187b076 (diff) | |
download | scummvm-rg350-56eae68e8bafde62e28af1cf5302d52424362684.tar.gz scummvm-rg350-56eae68e8bafde62e28af1cf5302d52424362684.tar.bz2 scummvm-rg350-56eae68e8bafde62e28af1cf5302d52424362684.zip |
re-enabled .sog and .so3 support for FT
svn-id: r12096
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/imuse_digi.cpp | 61 | ||||
-rw-r--r-- | scumm/imuse_digi.h | 4 | ||||
-rw-r--r-- | scumm/sound.cpp | 30 |
3 files changed, 40 insertions, 55 deletions
diff --git a/scumm/imuse_digi.cpp b/scumm/imuse_digi.cpp index 5d7102c0c4..09a1c0d45d 100644 --- a/scumm/imuse_digi.cpp +++ b/scumm/imuse_digi.cpp @@ -746,27 +746,23 @@ void IMuseDigital::callback() { } } -void IMuseDigital::startSound(int sound, byte *voc_src, int voc_size, int voc_rate) { +void IMuseDigital::startSound(int sound, byte *voiceBundleData, AudioInputStream *input) { debug(5, "IMuseDigital::startSound(%d)", sound); int l, r; for (l = 0; l < MAX_DIGITAL_CHANNELS; l++) { if (!_channel[l].used && !_channel[l].handle.isActive()) { byte *ptr, *s_ptr; - byte *_voiceVocData = (voc_src && voc_size > 0) ? voc_src : 0; - byte *_voiceBundleData = (voc_src && voc_size <= 0) ? voc_src : 0; - if ((sound == kTalkSoundID) && (_voiceBundleData)) { - s_ptr = ptr = _voiceBundleData; - } else if ((sound == kTalkSoundID) && (_voiceVocData)) { - // - s_ptr = ptr = 0; - } else if (sound != kTalkSoundID) { - ptr = _scumm->getResourceAddress(rtSound, sound); - s_ptr = ptr; + if (sound != kTalkSoundID) { + s_ptr = ptr = _scumm->getResourceAddress(rtSound, sound); if (ptr == NULL) { warning("IMuseDigital::startSound(%d) NULL resource pointer", sound); return; } + } else if (voiceBundleData) { + s_ptr = ptr = voiceBundleData; + } else if (input) { + s_ptr = ptr = 0; } else { error("IMuseDigital::startSound() unknown condition"); } @@ -782,26 +778,20 @@ void IMuseDigital::startSound(int sound, byte *voc_src, int voc_size, int voc_ra _channel[l].numMarkers = 0; _channel[l].idSound = sound; - - uint32 tag; - int32 size = 0; - - int freq, channels, bits; - int mixerFlags; - byte *data; - - if ((sound == kTalkSoundID) && (_voiceVocData) || (READ_UINT32(ptr) == MKID('Crea'))) { - if (ptr && READ_UINT32(ptr) == MKID('Crea')) { - int loops = 0; - voc_src = readVOCFromMemory(ptr, voc_size, voc_rate, loops); - } - freq = voc_rate; - size = voc_size; - bits = 8; - channels = 1; - mixerFlags = SoundMixer::FLAG_UNSIGNED; - data = voc_src; + + if (input) { + // Do nothing here, we already have an audio stream + } else if (READ_UINT32(ptr) == MKID('Crea')) { + // Create an AudioInputStream + input = makeVOCStream(ptr); } else if (READ_UINT32(ptr) == MKID('iMUS')) { + uint32 tag; + int32 size = 0; + + int freq, channels, bits; + int mixerFlags; + byte *data; + ptr += 16; freq = channels = bits = 0; do { @@ -863,7 +853,7 @@ void IMuseDigital::startSound(int sound, byte *voc_src, int voc_size, int voc_ra } } while (tag != MKID_BE('DATA')); - if ((sound == kTalkSoundID) && (_voiceBundleData)) { + if ((sound == kTalkSoundID) && voiceBundleData) { if (_scumm->_actorToPrintStrFor != 0xFF && _scumm->_actorToPrintStrFor != 0) { Actor *a = _scumm->derefActor(_scumm->_actorToPrintStrFor, "playBundleSound"); freq = (freq * a->talkFrequency) / 256; @@ -931,12 +921,15 @@ void IMuseDigital::startSound(int sound, byte *voc_src, int voc_size, int voc_ra memcpy(data, ptr, size); } else error("IMuseDigital::startSound(): Can't handle %d bit samples", bits); + + // Create an AudioInputStream + input = makeLinearInputStream(freq, mixerFlags | SoundMixer::FLAG_AUTOFREE, data, size, 0, 0); } else { error("IMuseDigital::startSound(): Unknown sound format"); } - // Create an AudioInputStream and hook it to the mixer. - _channel[l].stream = makeLinearInputStream(freq, mixerFlags | SoundMixer::FLAG_AUTOFREE, data, size, 0, 0); + // Set the audio stream for this new channel + _channel[l].stream = input; _channel[l].started = false; _channel[l].used = true; @@ -1424,7 +1417,7 @@ void IMuseDigital::playBundleSound(const char *sound) { if (ptr) { stopSound(kTalkSoundID); - startSound(kTalkSoundID, ptr); + startSound(kTalkSoundID, ptr, 0); free(ptr); } } diff --git a/scumm/imuse_digi.h b/scumm/imuse_digi.h index 0cfda38aa1..a81ea5c39c 100644 --- a/scumm/imuse_digi.h +++ b/scumm/imuse_digi.h @@ -128,7 +128,7 @@ public: void stopBundleMusic(); void playBundleSound(const char *sound); - void startSound(int sound, byte *src, int size = 0, int rate = 0); + void startSound(int sound, byte *voiceBundleData, AudioInputStream *input); public: IMuseDigital(ScummEngine *scumm); @@ -136,7 +136,7 @@ public: void setMasterVolume(int vol) {} - void startSound(int sound) { startSound(sound, 0, 0, 0); } + void startSound(int sound) { startSound(sound, 0, 0); } void stopSound(int sound); void stopAllSounds(); void pause(bool pause); diff --git a/scumm/sound.cpp b/scumm/sound.cpp index 42e7280329..13217e710c 100644 --- a/scumm/sound.cpp +++ b/scumm/sound.cpp @@ -34,7 +34,9 @@ #include "sound/audiocd.h" #include "sound/mididrv.h" #include "sound/mixer.h" +#include "sound/mp3.h" #include "sound/voc.h" +#include "sound/vorbis.h" namespace Scumm { @@ -811,27 +813,27 @@ void Sound::pauseSounds(bool pause) { void Sound::startSfxSound(File *file, int file_size, PlayingSoundHandle *handle, int id) { + AudioInputStream *input; + + if (file_size > 0) { if (_vorbis_mode) { #ifdef USE_VORBIS - _scumm->_mixer->playVorbis(handle, file, file_size, 255, 0, id); + input = makeVorbisStream(file, file_size); #endif } else { #ifdef USE_MAD - _scumm->_mixer->playMP3(handle, file, file_size, 255, 0, id); + input = makeMP3Stream(file, file_size); #endif } - return; + } else { + input = makeVOCStream(_sfxFile); } - int size; - int rate; - byte *data = loadVOCFile(_sfxFile, size, rate); - if (_scumm->_imuseDigital) { - _scumm->_imuseDigital->startSound(kTalkSoundID, data, size, rate); + _scumm->_imuseDigital->startSound(kTalkSoundID, 0, input); } else { - _scumm->_mixer->playRaw(handle, data, size, rate, SoundMixer::FLAG_AUTOFREE | SoundMixer::FLAG_UNSIGNED, id); + _scumm->_mixer->playInputStream(handle, input, false, 255, 0, id); } } @@ -844,16 +846,6 @@ File *Sound::openSfxFile() { * same directory */ offset_table = NULL; - // FIXME / TODO / HACK: for FT voice can only be loaded from original .sou - // files, not .so3 or .sog. This will be so until IMuseDigital gets fixed. - if (_scumm->_imuseDigital) { - sprintf(buf, "%s.sou", _scumm->getGameName()); - if (!file->open(buf, _scumm->getGameDataPath())) { - file->open("monster.sou", _scumm->getGameDataPath()); - } - return file; - } - #ifdef USE_MAD sprintf(buf, "%s.so3", _scumm->getGameName()); if (!file->open(buf, _scumm->getGameDataPath())) { |