diff options
-rw-r--r-- | engines/wage/sound.cpp | 23 | ||||
-rw-r--r-- | engines/wage/sound.h | 5 |
2 files changed, 24 insertions, 4 deletions
diff --git a/engines/wage/sound.cpp b/engines/wage/sound.cpp index 8a6d901ce1..6ab6ed5a47 100644 --- a/engines/wage/sound.cpp +++ b/engines/wage/sound.cpp @@ -45,23 +45,27 @@ * */ +#include "audio/audiostream.h" +#include "audio/mixer.h" +#include "audio/decoders/raw.h" #include "common/stream.h" #include "wage/wage.h" #include "wage/sound.h" +#include "wage/world.h" namespace Wage { static const int8 deltas[] = { 0,-49,-36,-25,-16,-9,-4,-1,0,1,4,9,16,25,36,49 }; Sound::Sound(Common::String name, Common::SeekableReadStream *data) : _name(name) { - int size = data->size() - 20; - _data = (byte *)calloc(2 * size, 1); + _size = data->size() - 20; + _data = (byte *)calloc(2 * _size, 1); data->skip(20); // Skip header byte value = 0x80; - for (int i = 0; i < size; i++) { + for (int i = 0; i < _size; i++) { byte d = data->readByte(); value += deltas[d & 0xf]; _data[i * 2] = value; @@ -75,7 +79,18 @@ Sound::~Sound() { } void WageEngine::playSound(Common::String soundName) { - warning("STUB: WageEngine::playSound(%s)", soundName.c_str()); + soundName.toLowercase(); + + if (!_world->_sounds.contains(soundName)) { + warning("Sound '%s' does not exist", soundName.c_str()); + return; + } + + Sound *s = _world->_sounds[soundName]; + + Audio::AudioStream *stream = Audio::makeRawStream(s->_data, s->_size, 11000, Audio::FLAG_UNSIGNED); + + _mixer->playStream(Audio::Mixer::kPlainSoundType, &s->_handle, stream); } void WageEngine::updateSoundTimerForScene(Scene *scene, bool firstTime) { diff --git a/engines/wage/sound.h b/engines/wage/sound.h index b3e91e18d0..101b5a0db6 100644 --- a/engines/wage/sound.h +++ b/engines/wage/sound.h @@ -48,6 +48,8 @@ #ifndef WAGE_SOUND_H #define WAGE_SOUND_H +#include "audio/mixer.h" + namespace Wage { class Sound { @@ -56,7 +58,10 @@ public: ~Sound(); Common::String _name; + uint _size; byte *_data; + + Audio::SoundHandle _handle; }; } // End of namespace Wage |