ULTIMA8: Adjust audio channel rate using pitch shift variable

This commit is contained in:
Matthew Jimenez 2024-01-20 17:46:34 -06:00
parent d89c9e1523
commit f7d13fdd35

View File

@ -21,6 +21,7 @@
#include "ultima/ultima8/misc/common_types.h"
#include "ultima/ultima8/audio/audio_channel.h"
#include "ultima/ultima8/audio/audio_process.h"
#include "ultima/ultima8/audio/audio_sample.h"
#include "common/memstream.h"
#include "audio/audiostream.h"
@ -92,7 +93,10 @@ void AudioChannel::playSample(AudioSample *sample, int loop, int priority, bool
// Play it
int vol = (_lVol + _rVol) / 2; // range is 0 ~ 255
int balance = (_rVol - _lVol) / 2; // range is -127 ~ +127
_mixer->playStream(isSpeech ? Audio::Mixer::kSpeechSoundType : Audio::Mixer::kSFXSoundType, &_soundHandle, stream, -1, vol, balance);
if (_pitchShift != AudioProcess::PITCH_SHIFT_NONE)
_mixer->setChannelRate(_soundHandle, stream->getRate() * pitchShift / AudioProcess::PITCH_SHIFT_NONE);
if (paused)
_mixer->pauseHandle(_soundHandle, true);
}