aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorEugene Sandulenko2017-08-08 10:15:59 +0200
committerEugene Sandulenko2017-08-08 11:25:55 +0200
commitd31628cb37300de6b7ff374ba224ef3e86abb367 (patch)
treee8f35b4794543bce85b915cdd38c8ed0216d97d5 /engines
parent0e2d14ac415faeec25226cef64b3443b0905eff9 (diff)
downloadscummvm-rg350-d31628cb37300de6b7ff374ba224ef3e86abb367.tar.gz
scummvm-rg350-d31628cb37300de6b7ff374ba224ef3e86abb367.tar.bz2
scummvm-rg350-d31628cb37300de6b7ff374ba224ef3e86abb367.zip
WAGE: Play sounds
Diffstat (limited to 'engines')
-rw-r--r--engines/wage/sound.cpp23
-rw-r--r--engines/wage/sound.h5
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