mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-13 21:31:53 +00:00
Finish support of compressed dubbing
Now even the length of a compressed stream is measured precisely and the dubbing sounds exactly like the original. svn-id: r50618
This commit is contained in:
parent
8d26e7c2d2
commit
0fd3558986
@ -166,10 +166,10 @@ void Animation::drawFrame(Surface *surface) {
|
||||
|
||||
const SoundSample *sample = _samples[_currentFrame];
|
||||
if (_hasChangedFrame && sample) {
|
||||
uint duration = _vm->_sound->playSound(sample, Audio::Mixer::kMaxChannelVolume, false);
|
||||
debugC(3, kDraciSoundDebugLevel,
|
||||
"Playing sample on animation %d, frame %d: %d+%d at %dHz",
|
||||
_id, _currentFrame, sample->_offset, sample->_length, sample->_frequency);
|
||||
_vm->_sound->playSound(sample, Audio::Mixer::kMaxChannelVolume, false);
|
||||
"Playing sample on animation %d, frame %d: %d+%d at %dHz: %dms",
|
||||
_id, _currentFrame, sample->_offset, sample->_length, sample->_frequency, duration);
|
||||
}
|
||||
_hasChangedFrame = false;
|
||||
}
|
||||
|
@ -729,10 +729,10 @@ void Script::talk(const Common::Array<int> ¶ms) {
|
||||
// Speak the dubbing if possible
|
||||
uint dubbingDuration = 0;
|
||||
if (sample) {
|
||||
dubbingDuration = (uint) (1000.0 * sample->_length / sample->_frequency + 500.0);
|
||||
dubbingDuration = _vm->_sound->playVoice(sample);
|
||||
debugC(3, kDraciSoundDebugLevel, "Playing sentence %d: %d+%d with duration %dms",
|
||||
sentenceID, sample->_offset, sample->_length, dubbingDuration);
|
||||
_vm->_sound->playVoice(sample);
|
||||
dubbingDuration += 500;
|
||||
}
|
||||
|
||||
// Record time
|
||||
|
@ -285,11 +285,11 @@ SndHandle *Sound::getHandle() {
|
||||
return NULL; // for compilers that don't support NORETURN
|
||||
}
|
||||
|
||||
void Sound::playSoundBuffer(Audio::SoundHandle *handle, const SoundSample &buffer, int volume,
|
||||
uint Sound::playSoundBuffer(Audio::SoundHandle *handle, const SoundSample &buffer, int volume,
|
||||
sndHandleType handleType, bool loop) {
|
||||
if (!buffer._stream && !buffer._data) {
|
||||
warning("Empty stream");
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
// Create a new SeekableReadStream which will be automatically disposed
|
||||
// after the sample stops playing. Do not dispose the original
|
||||
@ -335,22 +335,24 @@ void Sound::playSoundBuffer(Audio::SoundHandle *handle, const SoundSample &buffe
|
||||
default:
|
||||
error("Unsupported compression format %d", static_cast<int> (buffer._format));
|
||||
delete stream;
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const uint length = reader->getLength().msecs();
|
||||
const Audio::Mixer::SoundType soundType = (handleType == kVoiceHandle) ?
|
||||
Audio::Mixer::kSpeechSoundType : Audio::Mixer::kSFXSoundType;
|
||||
Audio::AudioStream *audio_stream = Audio::makeLoopingAudioStream(reader, loop ? 0 : 1);
|
||||
_mixer->playStream(soundType, handle, audio_stream, -1, volume);
|
||||
return length;
|
||||
}
|
||||
|
||||
void Sound::playSound(const SoundSample *buffer, int volume, bool loop) {
|
||||
uint Sound::playSound(const SoundSample *buffer, int volume, bool loop) {
|
||||
if (!buffer || _muteSound)
|
||||
return;
|
||||
return 0;
|
||||
SndHandle *handle = getHandle();
|
||||
|
||||
handle->type = kEffectHandle;
|
||||
playSoundBuffer(&handle->handle, *buffer, 2 * volume, handle->type, loop);
|
||||
return playSoundBuffer(&handle->handle, *buffer, 2 * volume, handle->type, loop);
|
||||
}
|
||||
|
||||
void Sound::pauseSound() {
|
||||
@ -374,13 +376,13 @@ void Sound::stopSound() {
|
||||
}
|
||||
}
|
||||
|
||||
void Sound::playVoice(const SoundSample *buffer) {
|
||||
uint Sound::playVoice(const SoundSample *buffer) {
|
||||
if (!buffer || _muteVoice)
|
||||
return;
|
||||
return 0;
|
||||
SndHandle *handle = getHandle();
|
||||
|
||||
handle->type = kVoiceHandle;
|
||||
playSoundBuffer(&handle->handle, *buffer, Audio::Mixer::kMaxChannelVolume, handle->type, false);
|
||||
return playSoundBuffer(&handle->handle, *buffer, Audio::Mixer::kMaxChannelVolume, handle->type, false);
|
||||
}
|
||||
|
||||
void Sound::pauseVoice() {
|
||||
|
@ -189,13 +189,13 @@ public:
|
||||
Sound(Audio::Mixer *mixer);
|
||||
~Sound() {}
|
||||
|
||||
void playSound(const SoundSample *buffer, int volume, bool loop);
|
||||
uint playSound(const SoundSample *buffer, int volume, bool loop);
|
||||
void pauseSound();
|
||||
void resumeSound();
|
||||
void stopSound();
|
||||
bool isMutedSound() const { return _muteSound; }
|
||||
|
||||
void playVoice(const SoundSample *buffer);
|
||||
uint playVoice(const SoundSample *buffer);
|
||||
void pauseVoice();
|
||||
void resumeVoice();
|
||||
void stopVoice();
|
||||
@ -209,7 +209,8 @@ public:
|
||||
int talkSpeed() const { return _talkSpeed; }
|
||||
|
||||
private:
|
||||
void playSoundBuffer(Audio::SoundHandle *handle, const SoundSample &buffer, int volume,
|
||||
// Returns the length of the sound sample in miliseconds.
|
||||
uint playSoundBuffer(Audio::SoundHandle *handle, const SoundSample &buffer, int volume,
|
||||
sndHandleType handleType, bool loop);
|
||||
|
||||
SndHandle *getHandle();
|
||||
|
Loading…
Reference in New Issue
Block a user