From 58139baf3710160c8382db14df26291d176e70cd Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Tue, 7 Sep 2010 20:18:30 +0000 Subject: MOHAWK: Sound cleanup Merge the Riven sound file code with the main Riven resource code and remove the mainSoundFile parameter from Sound::playSound(). Reasoning: The sound id's do not collide with the sound id's in the main data files. The sound archives only exist because the original CD version had the ability to choose between low and high quality audio. svn-id: r52631 --- engines/mohawk/sound.cpp | 37 ++----------------------------------- 1 file changed, 2 insertions(+), 35 deletions(-) (limited to 'engines/mohawk/sound.cpp') diff --git a/engines/mohawk/sound.cpp b/engines/mohawk/sound.cpp index 091bd68021..50a7d016f5 100644 --- a/engines/mohawk/sound.cpp +++ b/engines/mohawk/sound.cpp @@ -36,7 +36,6 @@ namespace Mohawk { Sound::Sound(MohawkEngine* vm) : _vm(vm) { - _rivenSoundFile = NULL; _midiDriver = NULL; _midiParser = NULL; @@ -51,7 +50,6 @@ Sound::Sound(MohawkEngine* vm) : _vm(vm) { Sound::~Sound() { stopSound(); stopAllSLST(); - delete _rivenSoundFile; if (_midiDriver) { _midiDriver->close(); @@ -64,15 +62,6 @@ Sound::~Sound() { } } -void Sound::loadRivenSounds(uint16 stack) { - static const char prefixes[] = { 'a', 'b', 'g', 'j', 'o', 'p', 'r', 't' }; - - if (!_rivenSoundFile) - _rivenSoundFile = new MohawkArchive(); - - _rivenSoundFile->open(Common::String(prefixes[stack]) + "_Sounds.mhk"); -} - void Sound::initMidi() { if (!(_vm->getFeatures() & GF_HASMIDI)) return; @@ -87,7 +76,7 @@ void Sound::initMidi() { _midiParser->setTimerRate(_midiDriver->getBaseTempo()); } -Audio::SoundHandle *Sound::playSound(uint16 id, bool mainSoundFile, byte volume, bool loop) { +Audio::SoundHandle *Sound::playSound(uint16 id, byte volume, bool loop) { debug (0, "Playing sound %d", id); SndHandle *handle = getHandle(); @@ -113,21 +102,9 @@ Audio::SoundHandle *Sound::playSound(uint16 id, bool mainSoundFile, byte volume, } else audStream = makeMohawkWaveStream(_vm->getRawData(ID_MSND, id)); break; - case GType_RIVEN: - if (mainSoundFile) - audStream = makeMohawkWaveStream(_rivenSoundFile->getRawData(ID_TWAV, id)); - else - audStream = makeMohawkWaveStream(_vm->getRawData(ID_TWAV, id)); - break; case GType_ZOOMBINI: audStream = makeMohawkWaveStream(_vm->getRawData(ID_SND, id)); break; - case GType_CSAMTRAK: - if (mainSoundFile) - audStream = makeMohawkWaveStream(_vm->getRawData(ID_TWAV, id)); - else - audStream = getCSAmtrakMusic(id); - break; case GType_LIVINGBOOKSV1: audStream = makeOldMohawkWaveStream(_vm->getRawData(ID_WAV, id)); break; @@ -304,7 +281,7 @@ void Sound::playSLSTSound(uint16 id, bool fade, bool loop, uint16 volume, int16 sndHandle.id = id; _currentSLSTSounds.push_back(sndHandle); - Audio::AudioStream *audStream = makeMohawkWaveStream(_rivenSoundFile->getRawData(ID_TWAV, id)); + Audio::AudioStream *audStream = makeMohawkWaveStream(_vm->getRawData(ID_TWAV, id)); // Loop here if necessary if (loop) @@ -336,16 +313,6 @@ void Sound::resumeSLST() { _vm->_mixer->pauseHandle(*_currentSLSTSounds[i].handle, false); } -Audio::AudioStream *Sound::getCSAmtrakMusic(uint16 id) { - char filename[18]; - sprintf(filename, "MUSIC/MUSIC%02d.MHK", id); - MohawkArchive *file = new MohawkArchive(); - file->open(filename); - Audio::AudioStream *audStream = makeMohawkWaveStream(file->getRawData(ID_TWAV, 2000 + id)); - delete file; - return audStream; -} - Audio::AudioStream *Sound::makeMohawkWaveStream(Common::SeekableReadStream *stream) { uint32 tag = 0; ADPC_Chunk adpc; -- cgit v1.2.3 From 0cba4f030691f83e487ddcc688214feef9a8b65e Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Wed, 8 Sep 2010 20:50:56 +0000 Subject: MOHAWK: Implement blocking sound in Riven Sounds that set the third argument of the playSound opcode to 1 (wherever they may be) will now block. The volume parameter of playSound is also now honored. Merge the Myst sound blocking code with this too. svn-id: r52643 --- engines/mohawk/sound.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'engines/mohawk/sound.cpp') diff --git a/engines/mohawk/sound.cpp b/engines/mohawk/sound.cpp index 50a7d016f5..4a8c923c01 100644 --- a/engines/mohawk/sound.cpp +++ b/engines/mohawk/sound.cpp @@ -124,6 +124,13 @@ Audio::SoundHandle *Sound::playSound(uint16 id, byte volume, bool loop) { return NULL; } +void Sound::playSoundBlocking(uint16 id, byte volume) { + Audio::SoundHandle *handle = playSound(id, volume); + + while (_vm->_mixer->isSoundHandleActive(*handle)) + _vm->_system->delayMillis(10); +} + void Sound::playMidi(uint16 id) { uint32 idTag; if (!(_vm->getFeatures() & GF_HASMIDI)) { @@ -165,6 +172,10 @@ void Sound::playMidi(uint16 id) { _midiDriver->setTimerCallback(_midiParser, MidiParser::timerCallback); } +byte Sound::convertRivenVolume(uint16 volume) { + return (volume == 256) ? 255 : volume; +} + void Sound::playSLST(uint16 index, uint16 card) { Common::SeekableReadStream *slstStream = _vm->getRawData(ID_SLST, card); SLSTRecord slstRecord; @@ -287,13 +298,9 @@ void Sound::playSLSTSound(uint16 id, bool fade, bool loop, uint16 volume, int16 if (loop) audStream = Audio::makeLoopingAudioStream((Audio::RewindableAudioStream *)audStream, 0); - // The max mixer volume is 255 and the max Riven volume is 256. Just change it to 255. - if (volume == 256) - volume = 255; - // TODO: Handle fading, possibly just raise the volume of the channel in increments? - _vm->_mixer->playStream(Audio::Mixer::kPlainSoundType, sndHandle.handle, audStream, -1, volume, convertBalance(balance)); + _vm->_mixer->playStream(Audio::Mixer::kPlainSoundType, sndHandle.handle, audStream, -1, convertRivenVolume(volume), convertBalance(balance)); } void Sound::stopSLSTSound(uint16 index, bool fade) { -- cgit v1.2.3