DRAGONS: Play sfx from vab tone range.

This commit is contained in:
Eric Fry 2020-08-29 14:39:37 +10:00
parent fe2046af4f
commit 55ff2f91bc
2 changed files with 9 additions and 1 deletions

View File

@ -441,8 +441,12 @@ void SoundManager::playSound(uint16 soundId, uint16 volumeId) {
if (vagID >= 0) {
Audio::SoundHandle *handle = getVoiceHandle(soundId);
if (handle) {
//TODO need to handle sfx where the requested key doesn't match the vag tone.
// We need to change pitch in this case.
_vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, handle, vabSound->getAudioStream(program, vagID), -1, _sfxVolume);
}
} else {
warning("Sound not found Program: %d, key %d", program, key);
}
}

View File

@ -158,7 +158,11 @@ void VabSound::loadToneAttributes(Common::SeekableReadStream *vhData) {
int16 VabSound::getVagID(uint16 program, uint16 key) {
if (program < _header.numVAG) {
for (int i = 0; i < _programAttrs[program].tones; i++) {
if (_toneAttrs[i].prog == program && _toneAttrs[i].min == key && _toneAttrs[i].max == key) {
if (_toneAttrs[i].prog == program && _toneAttrs[i].min <= key && _toneAttrs[i].max >= key) {
if (key != _toneAttrs[i].min) {
warning("Sfx key requested doesn't exactly match vab tone. TODO we need to change the playback pitch. key requested: %d tone match (min,max) (%d, %d)",
key, _toneAttrs[i].min, _toneAttrs[i].max);
}
return _toneAttrs[i].vag - 1;
}
}