diff --git a/engines/director/director.cpp b/engines/director/director.cpp index 50c4fbdb4ca3..28651fa8f5c2 100644 --- a/engines/director/director.cpp +++ b/engines/director/director.cpp @@ -41,6 +41,7 @@ #include "director/resource.h" #include "director/score.h" #include "director/lingo/lingo.h" +#include "director/sound.h" namespace Director { @@ -69,6 +70,8 @@ Common::Error DirectorEngine::run() { _lingo = new Lingo(); + _soundManager = new DirectorSound(); + //FIXME _mainArchive = new RIFFArchive(); _mainArchive->openFile("bookshelf_example.mmm"); diff --git a/engines/director/director.h b/engines/director/director.h index 205495a62adb..9750ad9cc850 100644 --- a/engines/director/director.h +++ b/engines/director/director.h @@ -42,6 +42,7 @@ enum DirectorGameID { class Archive; struct DirectorGameDescription; class Lingo; +class DirectorSound; class DirectorEngine : public ::Engine { public: @@ -77,6 +78,7 @@ class DirectorEngine : public ::Engine { Archive *_mainArchive; Common::MacResManager *_macBinary; + DirectorSound *_soundManager; Lingo *_lingo; }; diff --git a/engines/director/module.mk b/engines/director/module.mk index 6f2e2165a858..4c2628c07554 100644 --- a/engines/director/module.mk +++ b/engines/director/module.mk @@ -6,6 +6,7 @@ MODULE_OBJS = \ director.o \ resource.o \ score.o \ + sound.o \ lingo/lingo.o # This module can be built as a plugin diff --git a/engines/director/score.cpp b/engines/director/score.cpp index b95a50e352e2..25631d569d79 100644 --- a/engines/director/score.cpp +++ b/engines/director/score.cpp @@ -632,7 +632,6 @@ void Frame::readSprite(Common::SeekableReadStream &stream, uint16 offset, uint16 sprite._flags = stream.readUint16BE(); sprite._ink = static_cast(sprite._flags & 0x3f); //TODO more flags? sprite._trails = sprite._flags & 0x40; - debug("%d", sprite._trails); fieldPosition += 2; break; case kSpritePositionCastId: diff --git a/engines/director/sound.cpp b/engines/director/sound.cpp new file mode 100644 index 000000000000..35071c807285 --- /dev/null +++ b/engines/director/sound.cpp @@ -0,0 +1,67 @@ +/* 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. +* +*/ + +#include "director/sound.h" +#include "audio/decoders/wave.h" +#include "common/file.h" +#include "audio/decoders/aiff.h" +#include "common/system.h" +#include "common/debug.h" + +namespace Director { + +DirectorSound::DirectorSound() { + _soundHandle = new Audio::SoundHandle(); + _mixer = g_system->getMixer(); +} + +void DirectorSound::playWAV(Common::String filename) { + Common::File *file = new Common::File(); + + if (!file->open(filename)) { + warning("Failed to open %s", filename.c_str()); + delete file; + return; + } + + Audio::RewindableAudioStream *sound = Audio::makeWAVStream(file, DisposeAfterUse::YES); + _mixer->playStream(Audio::Mixer::kSFXSoundType, _soundHandle, sound); +} + +void DirectorSound::playAIFF(Common::String filename) { + + Common::File *file = new Common::File(); + if (!file->open(filename)) { + warning("Failed to open %s", filename.c_str()); + delete file; + return; + } + + Audio::RewindableAudioStream *sound = Audio::makeAIFFStream(file, DisposeAfterUse::YES); + _mixer->playStream(Audio::Mixer::kSFXSoundType, _soundHandle, sound); +} + +void DirectorSound::stopSound() { + _mixer->stopHandle(*_soundHandle); +} + +} //End of namespace Director diff --git a/engines/director/sound.h b/engines/director/sound.h new file mode 100644 index 000000000000..3d842c8b5195 --- /dev/null +++ b/engines/director/sound.h @@ -0,0 +1,48 @@ +/* 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. +* +*/ + +#include "audio/audiostream.h" +#include "audio/mixer.h" +#include "common/str.h" + + +#ifndef DIRECTOR_SOUND_H +#define DIRECTOR_SOUND_H +namespace Director { + +class DirectorSound { + +private: + Audio::SoundHandle *_soundHandle; + Audio::Mixer *_mixer; + +public: + DirectorSound(); + + void playWAV(Common::String filename); + void playAIFF(Common::String filename); + void stopSound(); +}; + +} // End of namespace Director + +#endif