diff options
-rw-r--r-- | engines/gob/module.mk | 1 | ||||
-rw-r--r-- | engines/gob/sound/protracker.cpp | 68 | ||||
-rw-r--r-- | engines/gob/sound/protracker.h | 52 | ||||
-rw-r--r-- | engines/gob/sound/sound.cpp | 24 | ||||
-rw-r--r-- | engines/gob/sound/sound.h | 7 |
5 files changed, 151 insertions, 1 deletions
diff --git a/engines/gob/module.mk b/engines/gob/module.mk index e02eddc866..0871ce59da 100644 --- a/engines/gob/module.mk +++ b/engines/gob/module.mk @@ -64,6 +64,7 @@ MODULE_OBJS := \ sound/pcspeaker.o \ sound/adlib.o \ sound/infogrames.o \ + sound/protracker.o \ sound/soundmixer.o \ sound/soundblaster.o \ sound/cdrom.o \ diff --git a/engines/gob/sound/protracker.cpp b/engines/gob/sound/protracker.cpp new file mode 100644 index 0000000000..891580ef40 --- /dev/null +++ b/engines/gob/sound/protracker.cpp @@ -0,0 +1,68 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "common/file.h" + +#include "gob/sound/protracker.h" + +namespace Gob { + +Protracker::Protracker(Audio::Mixer &mixer) : _mixer(&mixer) { + _protrackerStream = 0; +} + +Protracker::~Protracker() { + stop(); +} + +bool Protracker::play(const char *fileName) { + stop(); + + Common::File f; + + if (!f.open(fileName)) + return false; + + _protrackerStream = Audio::makeProtrackerStream(&f); + + if (!_protrackerStream) + return false; + + _mixer->playInputStream(Audio::Mixer::kMusicSoundType, &_handle, + _protrackerStream, -1, 255, 0, false); + + return true; +} + +void Protracker::stop() { + if (_protrackerStream) { + _mixer->stopHandle(_handle); + + delete _protrackerStream; + _protrackerStream = 0; + } +} + +} // End of namespace Gob diff --git a/engines/gob/sound/protracker.h b/engines/gob/sound/protracker.h new file mode 100644 index 0000000000..6270530427 --- /dev/null +++ b/engines/gob/sound/protracker.h @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#ifndef GOB_SOUND_PROTRACKER_H +#define GOB_SOUND_PROTRACKER_H + +#include "sound/mixer.h" +#include "sound/audiostream.h" +#include "sound/mods/protracker.h" + +namespace Gob { + +class Protracker { +public: + Protracker(Audio::Mixer &mixer); + ~Protracker(); + + bool play(const char *fileName); + void stop(); + +private: + Audio::Mixer *_mixer; + + Audio::AudioStream *_protrackerStream; + Audio::SoundHandle _handle; +}; + +} // End of namespace Gob + +#endif // GOB_SOUND_PROTRACKER_H diff --git a/engines/gob/sound/sound.cpp b/engines/gob/sound/sound.cpp index 4746bfa99a..dbb6b7685b 100644 --- a/engines/gob/sound/sound.cpp +++ b/engines/gob/sound/sound.cpp @@ -39,13 +39,16 @@ Sound::Sound(GobEngine *vm) : _vm(vm) { _adlib = 0; _infogrames = 0; + _protracker = 0; _cdrom = 0; _bgatmos = 0; if (!_vm->_noMusic && _vm->hasAdlib()) _adlib = new AdLib(*_vm->_mixer); - if (!_vm->_noMusic && (_vm->getPlatform() == Common::kPlatformAmiga)) + if (!_vm->_noMusic && (_vm->getPlatform() == Common::kPlatformAmiga)) { _infogrames = new Infogrames(*_vm->_mixer); + _protracker = new Protracker(*_vm->_mixer); + } if (_vm->isCD()) _cdrom = new CDROM; if (_vm->getGameType() == kGameTypeWoodruff) @@ -61,6 +64,7 @@ Sound::~Sound() { delete _blaster; delete _adlib; delete _infogrames; + delete _protracker; delete _cdrom; delete _bgatmos; @@ -183,6 +187,24 @@ bool Sound::infogramesLoadSong(const char *fileName) { return _infogrames->loadSong(fileName); } +bool Sound::protrackerPlay(const char *fileName) { + if (!_protracker) + return false; + + debugC(1, kDebugSound, "Protracker: Playing song \"%s\"", fileName); + + return _protracker->play(fileName); +} + +void Sound::protrackerStop() { + if (!_protracker) + return; + + debugC(1, kDebugSound, "Protracker: Stopping playback"); + + _protracker->stop(); +} + void Sound::infogramesPlay() { if (!_infogrames) return; diff --git a/engines/gob/sound/sound.h b/engines/gob/sound/sound.h index 6fde4660aa..dbdd580ec7 100644 --- a/engines/gob/sound/sound.h +++ b/engines/gob/sound/sound.h @@ -31,6 +31,7 @@ #include "gob/sound/soundblaster.h" #include "gob/sound/adlib.h" #include "gob/sound/infogrames.h" +#include "gob/sound/protracker.h" #include "gob/sound/cdrom.h" #include "gob/sound/bgatmosphere.h" @@ -102,6 +103,11 @@ public: void infogramesStop(); + // Protracker + bool protrackerPlay(const char *fileName); + void protrackerStop(); + + // CD-ROM void cdLoadLIC(const char *fname); void cdUnloadLIC(); @@ -139,6 +145,7 @@ private: SoundBlaster *_blaster; AdLib *_adlib; Infogrames *_infogrames; + Protracker *_protracker; CDROM *_cdrom; BackgroundAtmosphere *_bgatmos; }; |