diff options
author | Thomas Fach-Pedersen | 2015-02-10 19:33:35 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2016-09-29 22:33:38 +0200 |
commit | eba8ed5c6642cf3686c4fb7e28ceca9299e3a33a (patch) | |
tree | d8a555a186ce0f5f89573c048528227f5801b0b0 /engines | |
parent | 35ea84935ff3259aaa09946f0447a75e9b617086 (diff) | |
download | scummvm-rg350-eba8ed5c6642cf3686c4fb7e28ceca9299e3a33a.tar.gz scummvm-rg350-eba8ed5c6642cf3686c4fb7e28ceca9299e3a33a.tar.bz2 scummvm-rg350-eba8ed5c6642cf3686c4fb7e28ceca9299e3a33a.zip |
BLADERUNNER: Add audio_speech and Actor_Voice_Over
Diffstat (limited to 'engines')
-rw-r--r-- | engines/bladerunner/audio_speech.cpp | 96 | ||||
-rw-r--r-- | engines/bladerunner/audio_speech.h | 52 | ||||
-rw-r--r-- | engines/bladerunner/bladerunner.cpp | 16 | ||||
-rw-r--r-- | engines/bladerunner/bladerunner.h | 3 | ||||
-rw-r--r-- | engines/bladerunner/module.mk | 1 | ||||
-rw-r--r-- | engines/bladerunner/script/rc01.cpp | 12 | ||||
-rw-r--r-- | engines/bladerunner/script/script.cpp | 13 | ||||
-rw-r--r-- | engines/bladerunner/script/script.h | 2 |
8 files changed, 192 insertions, 3 deletions
diff --git a/engines/bladerunner/audio_speech.cpp b/engines/bladerunner/audio_speech.cpp new file mode 100644 index 0000000000..6fa9c9406a --- /dev/null +++ b/engines/bladerunner/audio_speech.cpp @@ -0,0 +1,96 @@ +/* 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 "bladerunner/audio_speech.h" + +#include "bladerunner/aud_stream.h" +#include "bladerunner/bladerunner.h" + +#include "common/debug.h" + +namespace BladeRunner { + +#define BUFFER_SIZE 200000 + +AudioSpeech::AudioSpeech(BladeRunnerEngine *vm) + : _vm(vm) +{ + _volume = 50; + _isMaybeActive = false; + _data = new byte[BUFFER_SIZE]; +} + +AudioSpeech::~AudioSpeech() { + delete[] _data; +} + +bool AudioSpeech::playSpeech(const char *name, int balance) { + + Common::ScopedPtr<Common::SeekableReadStream> r(_vm->getResourceStream(name)); + + if (!r) { + debug("AudioSpeech::playSpeech: AUD resource \"%s\" not found", name); + return false; + } + + if (r->size() > BUFFER_SIZE) { + debug("AudioSpeech::playSpeech: AUD larger than buffer size (%d > %d)", r->size(), BUFFER_SIZE); + return false; + } + + if (isPlaying()) { + stopSpeech(); + } + + r->read(_data, r->size()); + if (r->err()) { + debug("AudioSpeech::playSpeech: Error reading resource \"%s\"", name); + return false; + } + + AudStream *audioStream = new AudStream(_data); + + _vm->_mixer->playStream( + Audio::Mixer::kPlainSoundType, + &_soundHandle, + audioStream, + -1, + _volume * 255 / 100, + balance); + + _isMaybeActive = true; + + return true; +} + +void AudioSpeech::stopSpeech() { + _vm->_mixer->stopHandle(_soundHandle); +} + +bool AudioSpeech::isPlaying() { + if (!_isMaybeActive) + return false; + + return _isMaybeActive = _vm->_mixer->isSoundHandleActive(_soundHandle); +} + +} // End of namespace BladeRunner diff --git a/engines/bladerunner/audio_speech.h b/engines/bladerunner/audio_speech.h new file mode 100644 index 0000000000..e122422724 --- /dev/null +++ b/engines/bladerunner/audio_speech.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. + * + */ + +#ifndef BLADERUNNER_AUDIO_SPEECH_H +#define BLADERUNNER_AUDIO_SPEECH_H + +#include "audio/mixer.h" + +namespace BladeRunner { + +class BladeRunnerEngine; + +class AudioSpeech { +private: + BladeRunnerEngine *_vm; + int _volume; + bool _isMaybeActive; + Audio::SoundHandle _soundHandle; + byte *_data; + +public: + AudioSpeech(BladeRunnerEngine *vm); + ~AudioSpeech(); + + bool playSpeech(const char *name, int balance = 50); + void stopSpeech(); + bool isPlaying(); + void setVolume(int volume) { _volume = volume; } +}; + +} // End of namespace BladeRunner + +#endif diff --git a/engines/bladerunner/bladerunner.cpp b/engines/bladerunner/bladerunner.cpp index 48ffb7b2bc..d69a77c381 100644 --- a/engines/bladerunner/bladerunner.cpp +++ b/engines/bladerunner/bladerunner.cpp @@ -25,6 +25,7 @@ #include "bladerunner/ambient_sounds.h" #include "bladerunner/audio_player.h" +#include "bladerunner/audio_speech.h" #include "bladerunner/chapters.h" #include "bladerunner/clues.h" #include "bladerunner/gameinfo.h" @@ -59,6 +60,7 @@ BladeRunnerEngine::BladeRunnerEngine(OSystem *syst) _ambientSounds = new AmbientSounds(this); _audioPlayer = new AudioPlayer(this); + _audioSpeech = new AudioSpeech(this); _chapters = nullptr; _clues = nullptr; _gameInfo = nullptr; @@ -82,6 +84,7 @@ BladeRunnerEngine::~BladeRunnerEngine() { delete _gameInfo; delete _clues; delete _chapters; + delete _audioSpeech; delete _audioPlayer; delete _ambientSounds; @@ -301,6 +304,19 @@ void BladeRunnerEngine::handleEvents() { } } +void BladeRunnerEngine::loopActorSpeaking() { + if (!_audioSpeech->isPlaying()) + return; + + // playerLosesControl(); + + do { + gameTick(); + } while (_audioSpeech->isPlaying()); + + // playerGainsControl(); +} + void BladeRunnerEngine::outtakePlay(int id, bool noLocalization, int container) { Common::String name = _gameInfo->getOuttake(id); diff --git a/engines/bladerunner/bladerunner.h b/engines/bladerunner/bladerunner.h index 9d8e4afbc7..b0df9bdca0 100644 --- a/engines/bladerunner/bladerunner.h +++ b/engines/bladerunner/bladerunner.h @@ -38,6 +38,7 @@ namespace BladeRunner { class AmbientSounds; class AudioPlayer; +class AudioSpeech; class Chapters; class Clues; class GameInfo; @@ -56,6 +57,7 @@ public: AmbientSounds *_ambientSounds; AudioPlayer *_audioPlayer; + AudioSpeech *_audioSpeech; Chapters *_chapters; Clues *_clues; GameInfo *_gameInfo; @@ -100,6 +102,7 @@ public: void gameLoop(); void gameTick(); void handleEvents(); + void loopActorSpeaking(); void outtakePlay(int id, bool no_localization, int container = -1); diff --git a/engines/bladerunner/module.mk b/engines/bladerunner/module.mk index 64d5ba8ad1..fd23e94cbb 100644 --- a/engines/bladerunner/module.mk +++ b/engines/bladerunner/module.mk @@ -6,6 +6,7 @@ MODULE_OBJS = \ archive.o \ aud_stream.o \ audio_player.o \ + audio_speech.o \ bladerunner.o \ boundingbox.o \ chapters.o \ diff --git a/engines/bladerunner/script/rc01.cpp b/engines/bladerunner/script/rc01.cpp index 2fa577856f..81c4795956 100644 --- a/engines/bladerunner/script/rc01.cpp +++ b/engines/bladerunner/script/rc01.cpp @@ -118,7 +118,17 @@ void ScriptRC01::InitializeScene() { } void ScriptRC01::SceneLoaded() { - + if (!Game_Flag_Query(24)){ + // ADQ_Flush(); + Actor_Voice_Over(1830, 99); + Actor_Voice_Over(1850, 99); + if (!Game_Flag_Query(378)) { + Actor_Voice_Over(1860, 99); + I_Sez("MG: Is David Leary a self-respecting human or is he powered by rechargeable"); + I_Sez("batteries?\n"); + } + Game_Flag_Set(24); + } } void ScriptRC01::SceneFrameAdvanced(int frame) { diff --git a/engines/bladerunner/script/script.cpp b/engines/bladerunner/script/script.cpp index 8386fc22da..62754bea3c 100644 --- a/engines/bladerunner/script/script.cpp +++ b/engines/bladerunner/script/script.cpp @@ -26,6 +26,7 @@ #include "bladerunner/ambient_sounds.h" #include "bladerunner/audio_player.h" +#include "bladerunner/audio_speech.h" #include "bladerunner/clues.h" #include "bladerunner/gameflags.h" #include "bladerunner/gameinfo.h" @@ -108,7 +109,17 @@ void Script::SceneFrameAdvanced(int frame) { // ScriptBase::Actor_Set_Targetable // ScriptBase::Actor_Says // ScriptBase::Actor_Says_With_Pause -// ScriptBase::Actor_Voice_Over + +void ScriptBase::Actor_Voice_Over(int sentenceId, int actorId) { + // Wait for any existing speech to end + _vm->loopActorSpeaking(); + + // TODO: Hack - This needs to go through the actor class + char name[13]; + sprintf(name, "%02d-%04d.AUD", actorId, sentenceId); + _vm->_audioSpeech->playSpeech(name); +} + // ScriptBase::Actor_Start_Speech_Sample // ScriptBase::Actor_Start_Voice_Over_Sample // ScriptBase::Actor_Query_Which_Set_In diff --git a/engines/bladerunner/script/script.h b/engines/bladerunner/script/script.h index a6ac20b0cc..82f7be8bb5 100644 --- a/engines/bladerunner/script/script.h +++ b/engines/bladerunner/script/script.h @@ -84,7 +84,7 @@ protected: // Actor_Set_Targetable // Actor_Says // Actor_Says_With_Pause - // Actor_Voice_Over + void Actor_Voice_Over(int sentenceId, int actorId); // Actor_Start_Speech_Sample // Actor_Start_Voice_Over_Sample // Actor_Query_Which_Set_In |