Skip to content

Commit

Permalink
DIRECTOR: Add initial sound playback support
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Iskrich authored and sev- committed Aug 3, 2016
1 parent fd3c336 commit c9ac498
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 1 deletion.
3 changes: 3 additions & 0 deletions engines/director/director.cpp
Expand Up @@ -41,6 +41,7 @@
#include "director/resource.h"
#include "director/score.h"
#include "director/lingo/lingo.h"
#include "director/sound.h"

namespace Director {

Expand Down Expand Up @@ -69,6 +70,8 @@ Common::Error DirectorEngine::run() {

_lingo = new Lingo();

_soundManager = new DirectorSound();

//FIXME
_mainArchive = new RIFFArchive();
_mainArchive->openFile("bookshelf_example.mmm");
Expand Down
2 changes: 2 additions & 0 deletions engines/director/director.h
Expand Up @@ -42,6 +42,7 @@ enum DirectorGameID {
class Archive;
struct DirectorGameDescription;
class Lingo;
class DirectorSound;

class DirectorEngine : public ::Engine {
public:
Expand Down Expand Up @@ -77,6 +78,7 @@ class DirectorEngine : public ::Engine {

Archive *_mainArchive;
Common::MacResManager *_macBinary;
DirectorSound *_soundManager;

Lingo *_lingo;
};
Expand Down
1 change: 1 addition & 0 deletions engines/director/module.mk
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion engines/director/score.cpp
Expand Up @@ -632,7 +632,6 @@ void Frame::readSprite(Common::SeekableReadStream &stream, uint16 offset, uint16
sprite._flags = stream.readUint16BE();
sprite._ink = static_cast<inkType>(sprite._flags & 0x3f); //TODO more flags?
sprite._trails = sprite._flags & 0x40;
debug("%d", sprite._trails);
fieldPosition += 2;
break;
case kSpritePositionCastId:
Expand Down
67 changes: 67 additions & 0 deletions 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
48 changes: 48 additions & 0 deletions 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

0 comments on commit c9ac498

Please sign in to comment.