diff options
author | uruk | 2014-07-24 18:55:09 +0200 |
---|---|---|
committer | uruk | 2014-07-24 18:55:09 +0200 |
commit | ff97d52d728a0a47f421dfdfabb40b30f0b1c920 (patch) | |
tree | a90b9c8db40ecb3d408055d7cd0709b9545d33e7 /engines/cge2 | |
parent | 24cc8a8762ded511e8f69ee2790f38b913ddcae9 (diff) | |
download | scummvm-rg350-ff97d52d728a0a47f421dfdfabb40b30f0b1c920.tar.gz scummvm-rg350-ff97d52d728a0a47f421dfdfabb40b30f0b1c920.tar.bz2 scummvm-rg350-ff97d52d728a0a47f421dfdfabb40b30f0b1c920.zip |
CGE2: Distinguish SFX from speech when playing sounds.
Now the sound options of ScummVM are taken into account when playing these two types of sounds. Until now, everything was considered SFX sound.
Diffstat (limited to 'engines/cge2')
-rw-r--r-- | engines/cge2/cge2.h | 3 | ||||
-rw-r--r-- | engines/cge2/snail.cpp | 8 | ||||
-rw-r--r-- | engines/cge2/sound.cpp | 40 | ||||
-rw-r--r-- | engines/cge2/sound.h | 7 |
4 files changed, 36 insertions, 22 deletions
diff --git a/engines/cge2/cge2.h b/engines/cge2/cge2.h index 363c7c431c..380e7da04c 100644 --- a/engines/cge2/cge2.h +++ b/engines/cge2/cge2.h @@ -35,6 +35,7 @@ #include "engines/advancedDetector.h" #include "common/system.h" #include "cge2/fileio.h" +#include "audio/mixer.h" namespace CGE2 { @@ -249,7 +250,7 @@ public: void snCycle(int cnt); void snWalk(Sprite *spr, int val); void snReach(Sprite *spr, int val); - void snSound(Sprite *spr, int wav); + void snSound(Sprite *spr, int wav, Audio::Mixer::SoundType soundType = Audio::Mixer::kSFXSoundType); void snRoom(Sprite *spr, bool on); void snDim(Sprite *spr, int val); void snGhost(Bitmap *bmp); diff --git a/engines/cge2/snail.cpp b/engines/cge2/snail.cpp index f6c6e2d71f..aebe1f0778 100644 --- a/engines/cge2/snail.cpp +++ b/engines/cge2/snail.cpp @@ -75,7 +75,7 @@ void CommandHandler::runCommand() { if (_vm->_fx->exist(_vm->_soundStat._ref[1], _vm->_soundStat._ref[0])) { int16 oldRepeat = _vm->_sound->getRepeat(); _vm->_sound->setRepeat(1); - _vm->_sound->play(_vm->_fx->load(_vm->_soundStat._ref[1], _vm->_soundStat._ref[0]), _vm->_sound->_smpinf._span); + _vm->_sound->play(Audio::Mixer::kSFXSoundType, _vm->_fx->load(_vm->_soundStat._ref[1], _vm->_soundStat._ref[0]), _vm->_sound->_smpinf._span); _vm->_sound->setRepeat(oldRepeat); return; } @@ -676,7 +676,7 @@ void CGE2Engine::snReach(Sprite *spr, int val) { ((Hero *)spr)->reach(val); } -void CGE2Engine::snSound(Sprite *spr, int wav) { +void CGE2Engine::snSound(Sprite *spr, int wav, Audio::Mixer::SoundType soundType) { if (wav == -1) _sound->stop(); else { @@ -687,7 +687,7 @@ void CGE2Engine::snSound(Sprite *spr, int wav) { _soundStat._ref[1] = wav; _soundStat._ref[0] = !_fx->exist(_soundStat._ref[1]); - _sound->play(_fx->load(_soundStat._ref[1], _soundStat._ref[0]), + _sound->play(soundType, _fx->load(_soundStat._ref[1], _soundStat._ref[0]), (spr) ? (spr->_pos2D.x / (kScrWidth / 16)) : 8); } } @@ -746,7 +746,7 @@ void CGE2Engine::snSay(Sprite *spr, int val) { i -= 100; int16 oldRepeat = _sound->getRepeat(); _sound->setRepeat(1); - snSound(spr, i); + snSound(spr, i, Audio::Mixer::kSpeechSoundType); _sound->setRepeat(oldRepeat); _soundStat._wait = &_sound->_smpinf._counter; } diff --git a/engines/cge2/sound.cpp b/engines/cge2/sound.cpp index b42ba188b2..27a3af826c 100644 --- a/engines/cge2/sound.cpp +++ b/engines/cge2/sound.cpp @@ -26,8 +26,6 @@ */ #include "cge2/sound.h" -//#include "cge/text.h" -//#include "cge/cge_main.h" #include "common/config-manager.h" #include "common/memstream.h" #include "audio/decoders/raw.h" @@ -63,7 +61,7 @@ void Sound::open() { setRepeat(1); if (_vm->_commandHandlerTurbo != nullptr) _vm->switchSay(); - play(_vm->_fx->load(99, 99)); + play(Audio::Mixer::kSFXSoundType, _vm->_fx->load(99, 99)); } void Sound::setRepeat(int16 count) { @@ -74,47 +72,61 @@ int16 Sound::getRepeat() { return _soundRepeatCount; } -void Sound::play(DataCk *wav, int pan) { +void Sound::play(Audio::Mixer::SoundType soundType, DataCk *wav, int pan) { if (wav) { stop(); _smpinf._saddr = &*(wav->addr()); _smpinf._slen = (uint16)wav->size(); _smpinf._span = pan; _smpinf._counter = getRepeat(); - sndDigiStart(&_smpinf); + sndDigiStart(&_smpinf, soundType); } } -void Sound::sndDigiStart(SmpInfo *PSmpInfo) { +void Sound::sndDigiStart(SmpInfo *PSmpInfo, Audio::Mixer::SoundType soundType) { // Create an audio stream wrapper for sound Common::MemoryReadStream *stream = new Common::MemoryReadStream(PSmpInfo->_saddr, PSmpInfo->_slen, DisposeAfterUse::NO); _audioStream = Audio::makeWAVStream(stream, DisposeAfterUse::YES); + // Decide which handle to use + Audio::SoundHandle *handle = nullptr; + switch (soundType) { + case Audio::Mixer::kSFXSoundType: + handle = &_soundHandle; + break; + case Audio::Mixer::kSpeechSoundType: + handle = &_speechHandle; + break; + default: + break; + } + // Start the new sound - _vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundHandle, + _vm->_mixer->playStream(soundType, handle, Audio::makeLoopingAudioStream(_audioStream, (uint)PSmpInfo->_counter)); // CGE pan: // 8 = Center // Less = Left // More = Right - _vm->_mixer->setChannelBalance(_soundHandle, (int8)CLIP(((PSmpInfo->_span - 8) * 16), -127, 127)); + _vm->_mixer->setChannelBalance(*handle, (int8)CLIP(((PSmpInfo->_span - 8) * 16), -127, 127)); } void Sound::stop() { - sndDigiStop(&_smpinf); + sndDigiStop(_soundHandle); + sndDigiStop(_speechHandle); + _audioStream = nullptr; } void Sound::checkSoundHandle() { - if (!_vm->_mixer->isSoundHandleActive(_soundHandle)) + if (!_vm->_mixer->isSoundHandleActive(_speechHandle)) _smpinf._counter = 0; } -void Sound::sndDigiStop(SmpInfo *PSmpInfo) { - if (_vm->_mixer->isSoundHandleActive(_soundHandle)) - _vm->_mixer->stopHandle(_soundHandle); - _audioStream = nullptr; +void Sound::sndDigiStop(Audio::SoundHandle &handle) { + if (_vm->_mixer->isSoundHandleActive(handle)) + _vm->_mixer->stopHandle(handle); } Fx::Fx(CGE2Engine *vm, int size) : _current(nullptr), _vm(vm) { diff --git a/engines/cge2/sound.h b/engines/cge2/sound.h index e2e9482799..7dd549ca16 100644 --- a/engines/cge2/sound.h +++ b/engines/cge2/sound.h @@ -72,7 +72,7 @@ public: ~Sound(); void open(); void close(); - void play(DataCk *wav, int pan = 8); + void play(Audio::Mixer::SoundType soundType, DataCk *wav, int pan = 8); int16 getRepeat(); void setRepeat(int16 count); void stop(); @@ -81,10 +81,11 @@ private: int _soundRepeatCount; CGE2Engine *_vm; Audio::SoundHandle _soundHandle; + Audio::SoundHandle _speechHandle; Audio::RewindableAudioStream *_audioStream; - void sndDigiStart(SmpInfo *PSmpInfo); - void sndDigiStop(SmpInfo *PSmpInfo); + void sndDigiStart(SmpInfo *PSmpInfo, Audio::Mixer::SoundType soundType); + void sndDigiStop(Audio::SoundHandle &handle); }; class Fx { |