[Scummvm-git-logs] scummvm master -> 06041c5db82456dfcdd374ac0047783c05466336
sev-
noreply at scummvm.org
Mon Nov 3 22:25:00 UTC 2025
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
06041c5db8 DIRECTOR: Generate cuePassed events for sounds
Commit: 06041c5db82456dfcdd374ac0047783c05466336
https://github.com/scummvm/scummvm/commit/06041c5db82456dfcdd374ac0047783c05466336
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2025-11-03T23:24:50+01:00
Commit Message:
DIRECTOR: Generate cuePassed events for sounds
Changed paths:
engines/director/score.cpp
engines/director/sound.cpp
engines/director/sound.h
diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index f8264a50874..a8846f66995 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -359,6 +359,8 @@ void Score::step() {
if (_movie->_currentHoveredSpriteId) {
_movie->processEvent(kEventMouseWithin, _movie->_currentHoveredSpriteId);
}
+
+ _soundManager->processCuePoints();
} else if (_version >= kFileVer500) {
// In D5, these events are only generated if a mouse button is pressed
if (_movie->_currentHoveredSpriteId && g_system->getEventManager()->getButtonState() != 0) {
diff --git a/engines/director/sound.cpp b/engines/director/sound.cpp
index fdb7d1c6148..6112581f033 100644
--- a/engines/director/sound.cpp
+++ b/engines/director/sound.cpp
@@ -744,6 +744,41 @@ uint8 DirectorSound::getChannelFaderR(int channel) {
return _mixer->getChannelFaderR(_channels[channel]->handle);
}
+void DirectorSound::processCuePoints() {
+ for (auto &it : _channels) {
+ SoundChannel *channel = it._value;
+
+ const SoundID &lastPlayedSound = channel->lastPlayedSound;
+ if (lastPlayedSound.type == kSoundCast) {
+ CastMemberID memberID(lastPlayedSound.u.cast.member, lastPlayedSound.u.cast.castLib);
+ SoundCastMember *soundCast = (SoundCastMember *)_window->getCurrentMovie()->getCastMember(memberID);
+
+ if (!soundCast)
+ continue;
+
+ if (soundCast->_cuePoints.empty())
+ continue;
+
+ uint32 elapsedTime = _mixer->getSoundElapsedTime(channel->handle);
+
+ if (!elapsedTime)
+ continue;
+
+ for (uint i = channel->lastCuePointIndex + 1; i < soundCast->_cuePoints.size(); i++) {
+ int32 cuePoint = soundCast->_cuePoints[i];
+
+ if (cuePoint > elapsedTime)
+ break;
+
+ debugC(5, kDebugSound, "DirectorSound::processCuePoints(): cue point %d reached on channel %d", cuePoint, it._key);
+
+ _window->getCurrentMovie()->processEvent(kEventCuePassed, i);
+
+ channel->lastCuePointIndex = i;
+ }
+ }
+ }
+}
SNDDecoder::SNDDecoder()
diff --git a/engines/director/sound.h b/engines/director/sound.h
index d457b6aacd6..fae22ba74a8 100644
--- a/engines/director/sound.h
+++ b/engines/director/sound.h
@@ -145,6 +145,7 @@ struct SoundChannel {
int pitchShiftPercent;
int originalRate;
FadeParams *fade;
+ int lastCuePointIndex;
// a non-zero sound ID if the channel is a puppet. i.e. it's controlled by lingo
SoundID puppet;
@@ -158,7 +159,9 @@ struct SoundChannel {
// a stop at the end of a loop.
Audio::LoopableAudioStream *loopPtr;
- SoundChannel(): handle(), lastPlayedSound(SoundID()), stopOnZero(true), volume(255), originalRate(-1), pitchShiftPercent(100), fade(nullptr), puppet(SoundID()), newPuppet(false), movieChanged(false), loopPtr(nullptr) {}
+ SoundChannel(): handle(), lastPlayedSound(SoundID()), stopOnZero(true), volume(255), originalRate(-1),
+ pitchShiftPercent(100), fade(nullptr), puppet(SoundID()), newPuppet(false), movieChanged(false), loopPtr(nullptr),
+ lastCuePointIndex(-1) {}
};
class DirectorSound {
@@ -226,6 +229,8 @@ public:
void setChannelDefaultVolume(int soundChannel);
void setChannelPitchShift(int soundChannel, int pitchShiftPercent);
+ void processCuePoints();
+
private:
void setLastPlayedSound(int soundChannel, SoundID soundId, bool stopOnZero = true);
bool isLastPlayedSound(int soundChannel, const SoundID &soundId);
More information about the Scummvm-git-logs
mailing list