[Scummvm-git-logs] scummvm master -> 6b9787bcc4ca09418b6dbd727dd74b72a143d345
NMIError
noreply at scummvm.org
Fri Jul 8 14:29:03 UTC 2022
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
6b9787bcc4 CHEWY: Fix SFX repeats
Commit: 6b9787bcc4ca09418b6dbd727dd74b72a143d345
https://github.com/scummvm/scummvm/commit/6b9787bcc4ca09418b6dbd727dd74b72a143d345
Author: Coen Rampen (crampen at gmail.com)
Date: 2022-07-08T16:28:52+02:00
Commit Message:
CHEWY: Fix SFX repeats
Changed paths:
engines/chewy/detail.cpp
engines/chewy/sound.cpp
engines/chewy/sound.h
engines/chewy/video/cfo_decoder.cpp
diff --git a/engines/chewy/detail.cpp b/engines/chewy/detail.cpp
index 8e3a9c63519..2551a4ec473 100644
--- a/engines/chewy/detail.cpp
+++ b/engines/chewy/detail.cpp
@@ -400,7 +400,7 @@ void Detail::plot_ani_details(int16 scrx, int16 scry, int16 start, int16 end, in
if (adiptr->sfx.sound_start[k] == adiptr->ani_count &&
!adiptr->delay_count) {
const uint channel = adiptr->sfx.channel[k] & 7;
- sound->playSound(sfxIndex, channel, false /*adiptr->sfx.repeats[k]*/, adiptr->sfx.volume[k], adiptr->sfx.stereo[k]);
+ sound->playSound(sfxIndex, channel, adiptr->sfx.repeats[k], adiptr->sfx.volume[k], adiptr->sfx.stereo[k]);
}
}
}
@@ -494,7 +494,8 @@ void Detail::playSound(int16 nr, int16 slot) {
const int16 sfxSlot = _rdi.Ainfo[nr].sfx.sound_index[slot];
if (sfxSlot != -1) {
const int16 sfxIndex = _rdi.detailSfxIndex[sfxSlot];
- g_engine->_sound->playSound(sfxIndex, slot);
+ g_engine->_sound->playSound(sfxIndex, slot,
+ _rdi.Ainfo[nr].sfx.repeats[slot], _rdi.Ainfo[nr].sfx.volume[slot], _rdi.Ainfo[nr].sfx.stereo[slot]);
}
}
diff --git a/engines/chewy/sound.cpp b/engines/chewy/sound.cpp
index 86344cdaae1..45ccf2d05ae 100644
--- a/engines/chewy/sound.cpp
+++ b/engines/chewy/sound.cpp
@@ -46,7 +46,7 @@ Sound::~Sound() {
delete _speechRes;
}
-void Sound::playSound(int num, uint channel, bool loop, uint16 volume, uint16 balance) {
+void Sound::playSound(int num, uint channel, uint16 loops, uint16 volume, uint16 balance) {
if (num < 0)
return;
@@ -54,20 +54,20 @@ void Sound::playSound(int num, uint channel, bool loop, uint16 volume, uint16 ba
uint8 *data = (uint8 *)MALLOC(sound->size);
memcpy(data, sound->data, sound->size);
- playSound(data, sound->size, channel, loop, volume, balance);
+ playSound(data, sound->size, channel, loops, volume, balance);
delete[] sound->data;
delete sound;
}
-void Sound::playSound(uint8 *data, uint32 size, uint channel, bool loop, uint16 volume, uint16 balance, DisposeAfterUse::Flag dispose) {
+void Sound::playSound(uint8 *data, uint32 size, uint channel, uint16 loops, uint16 volume, uint16 balance, DisposeAfterUse::Flag dispose) {
stopSound(channel);
Audio::AudioStream *stream = Audio::makeLoopingAudioStream(
new ChewyVocStream(
new Common::MemorySeekableReadWriteStream(data, size, dispose),
dispose),
- loop ? 0 : 1);
+ loops);
_mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundHandle[channel], stream, -1,
convertVolume(volume), convertBalance(balance));
diff --git a/engines/chewy/sound.h b/engines/chewy/sound.h
index 921aa61a074..17cfcc0ab93 100644
--- a/engines/chewy/sound.h
+++ b/engines/chewy/sound.h
@@ -43,8 +43,8 @@ public:
Sound(Audio::Mixer *mixer);
virtual ~Sound();
- void playSound(int num, uint channel = 0, bool loop = false, uint16 volume = 63, uint16 balance = 63);
- void playSound(uint8 *data, uint32 size, uint channel = 0, bool loop = false, uint16 volume = 63, uint16 balance = 63, DisposeAfterUse::Flag dispose = DisposeAfterUse::YES);
+ void playSound(int num, uint channel = 0, uint16 loops = 1, uint16 volume = 63, uint16 balance = 63);
+ void playSound(uint8 *data, uint32 size, uint channel = 0, uint16 loops = 1, uint16 volume = 63, uint16 balance = 63, DisposeAfterUse::Flag dispose = DisposeAfterUse::YES);
void pauseSound(uint channel);
void resumeSound(uint channel);
void stopSound(uint channel = 0);
diff --git a/engines/chewy/video/cfo_decoder.cpp b/engines/chewy/video/cfo_decoder.cpp
index 6db9dbc31e7..db995614d1a 100644
--- a/engines/chewy/video/cfo_decoder.cpp
+++ b/engines/chewy/video/cfo_decoder.cpp
@@ -264,11 +264,13 @@ void CfoDecoder::CfoVideoTrack::handleCustomFrame() {
case kChunkPlayVoc:
number = _fileStream->readUint16LE();
channel = _fileStream->readUint16LE();
- volume = _fileStream->readUint16LE();// * Audio::Mixer::kMaxChannelVolume / 63;
+ volume = _fileStream->readUint16LE();
repeat = _fileStream->readUint16LE();
assert(number < MAX_SOUND_EFFECTS);
- _sound->playSound(_soundEffects[number], _soundEffectSize[number], channel, repeat,
+ // Repeat is the number of times the sound should be repeated, so
+ // 0 means play once, 1 twice etc. 255 means repeat until stopped.
+ _sound->playSound(_soundEffects[number], _soundEffectSize[number], channel, repeat == 255 ? 0 : repeat + 1,
volume * _sfxGlobalVolume / 63, _sfxBalances[channel], DisposeAfterUse::NO);
break;
case kChunkSetSoundVolume:
More information about the Scummvm-git-logs
mailing list