diff options
author | Sven Hesse | 2008-05-08 15:51:02 +0000 |
---|---|---|
committer | Sven Hesse | 2008-05-08 15:51:02 +0000 |
commit | 18db41db506b1e18e050e8dded44dc8501b9bc8f (patch) | |
tree | 70915fc5e973052e2ea6b2d1034e1b42f11b9c7b /engines/gob/sound/sound.cpp | |
parent | a9b4058ba9fd94de7bd293b0763d71f9f90f84bc (diff) | |
download | scummvm-rg350-18db41db506b1e18e050e8dded44dc8501b9bc8f.tar.gz scummvm-rg350-18db41db506b1e18e050e8dded44dc8501b9bc8f.tar.bz2 scummvm-rg350-18db41db506b1e18e050e8dded44dc8501b9bc8f.zip |
Implemented the background "music" / atmospheric sounds in Woodruff
svn-id: r31949
Diffstat (limited to 'engines/gob/sound/sound.cpp')
-rw-r--r-- | engines/gob/sound/sound.cpp | 64 |
1 files changed, 63 insertions, 1 deletions
diff --git a/engines/gob/sound/sound.cpp b/engines/gob/sound/sound.cpp index 5c375c260a..63b74ca36f 100644 --- a/engines/gob/sound/sound.cpp +++ b/engines/gob/sound/sound.cpp @@ -39,6 +39,7 @@ Sound::Sound(GobEngine *vm) : _vm(vm) { _adlib = 0; _infogrames = 0; _cdrom = 0; + _bgatmos = 0; if (!_vm->_noMusic && _vm->hasAdlib()) _adlib = new AdLib(*_vm->_mixer); @@ -46,6 +47,8 @@ Sound::Sound(GobEngine *vm) : _vm(vm) { _infogrames = new Infogrames(*_vm->_mixer); if (_vm->isCD()) _cdrom = new CDROM; + if (_vm->getGameType() == kGameTypeWoodruff) + _bgatmos = new BackgroundAtmosphere(*_vm->_mixer); } Sound::~Sound() { @@ -85,10 +88,18 @@ int Sound::sampleGetNextFreeSlot() const { return -1; } -bool Sound::sampleLoad(SoundDesc *sndDesc, const char *fileName) { +bool Sound::sampleLoad(SoundDesc *sndDesc, const char *fileName, bool tryExist) { if (!sndDesc) return false; + int16 handle = _vm->_dataIO->openData(fileName); + if (handle < 0) { + warning("Can't open sample file \"%s\"", fileName); + return false; + } + + _vm->_dataIO->closeData(handle); + byte *data; uint32 size; @@ -458,4 +469,55 @@ void Sound::cdTest(int trySubst, const char *label) { _cdrom->testCD(trySubst, label); } +void Sound::bgPlay(const char *base, int count) { + if (!_bgatmos) + return; + + _bgatmos->stop(); + _bgatmos->queueClear(); + + int length = strlen(base) + 7; + char *fileName = new char[length]; + SoundDesc *sndDesc; + + for (int i = 1; i <= count; i++) { + snprintf(fileName, length, "%s%02d.SND", base, i); + + sndDesc = new SoundDesc; + if (sampleLoad(sndDesc, fileName)) + _bgatmos->queueSample(*sndDesc); + } + + _bgatmos->play(); +} + +void Sound::bgStop() { + if (!_bgatmos) + return; + + _bgatmos->stop(); + _bgatmos->queueClear(); +} + +void Sound::bgSetPlayMode(BackgroundAtmosphere::PlayMode mode) { + if (!_bgatmos) + return; + + _bgatmos->setPlayMode(mode); +} + +void Sound::bgShade() { + if (!_bgatmos) + return; + + _bgatmos->shade(); +} + +void Sound::bgUnshade() { + if (!_bgatmos) + return; + + _bgatmos->unshade(); +} + } // End of namespace Gob |