From 5a32f3f502de47486368dfcbbc271e167a596d44 Mon Sep 17 00:00:00 2001 From: Fabio Battaglia Date: Sun, 24 May 2009 08:27:33 +0000 Subject: tinsel: sound samples and speech support for Discworld PSX using VAG. Based on a patch provided by clone2727 svn-id: r40852 --- engines/tinsel/sound.cpp | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) (limited to 'engines/tinsel') diff --git a/engines/tinsel/sound.cpp b/engines/tinsel/sound.cpp index 54178a898a..47b7ffc51a 100644 --- a/engines/tinsel/sound.cpp +++ b/engines/tinsel/sound.cpp @@ -40,6 +40,7 @@ #include "sound/mixer.h" #include "sound/adpcm.h" +#include "sound/vag.h" #include "gui/message.h" @@ -99,24 +100,37 @@ bool SoundManager::playSample(int id, Audio::Mixer::SoundType type, Audio::Sound uint32 sampleLen = _sampleStream.readUint32LE(); if (_sampleStream.ioFailed()) error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage)); + + if (TinselV1PSX) { + // Read the stream and create a VAG Audio stream + Audio::AudioStream *vagStream = new Audio::VagStream(_sampleStream.readStream(sampleLen), false, 44100); + + // FIXME: Should set this in a different place ;) + _vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, volSound); + //_vm->_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, soundVolumeMusic); + _vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, volVoice); + + // Play the audio stream + _vm->_mixer->playInputStream(type, &curChan.handle, vagStream); + } else { + // allocate a buffer + void *sampleBuf = malloc(sampleLen); + assert(sampleBuf); - // allocate a buffer - void *sampleBuf = malloc(sampleLen); - assert(sampleBuf); - - // read all of the sample - if (_sampleStream.read(sampleBuf, sampleLen) != sampleLen) - error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage)); + // read all of the sample + if (_sampleStream.read(sampleBuf, sampleLen) != sampleLen) + error(FILE_IS_CORRUPT, _vm->getSampleFile(sampleLanguage)); - // FIXME: Should set this in a different place ;) - _vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, volSound); - //_vm->_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, soundVolumeMusic); - _vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, volVoice); + // FIXME: Should set this in a different place ;) + _vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, volSound); + //_vm->_mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, soundVolumeMusic); + _vm->_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, volVoice); - // play it - _vm->_mixer->playRaw(type, &curChan.handle, sampleBuf, sampleLen, 22050, - Audio::Mixer::FLAG_AUTOFREE | Audio::Mixer::FLAG_UNSIGNED); + // play it + _vm->_mixer->playRaw(type, &curChan.handle, sampleBuf, sampleLen, 22050, + Audio::Mixer::FLAG_AUTOFREE | Audio::Mixer::FLAG_UNSIGNED); + } if (handle) *handle = curChan.handle; -- cgit v1.2.3