tinsel: sound samples and speech support for Discworld PSX using VAG. Based on a patch provided by clone2727

svn-id: r40852
This commit is contained in:
Fabio Battaglia
2009-05-24 08:27:33 +00:00
parent 57e104c625
commit 5a32f3f502
+28 -14
View File
@@ -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;