[Scummvm-git-logs] scummvm master -> 647c853e1f2c0479c462262209b8741690c71d46

bluegr noreply at scummvm.org
Fri Jan 10 19:00:08 UTC 2025


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:
647c853e1f SCUMM: Hook SE effects for MI1SE and MI2SE


Commit: 647c853e1f2c0479c462262209b8741690c71d46
    https://github.com/scummvm/scummvm/commit/647c853e1f2c0479c462262209b8741690c71d46
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-01-10T20:59:29+02:00

Commit Message:
SCUMM: Hook SE effects for MI1SE and MI2SE

Changed paths:
    engines/scumm/sound.cpp
    engines/scumm/soundcd.cpp
    engines/scumm/soundse.cpp
    engines/scumm/soundse.h


diff --git a/engines/scumm/sound.cpp b/engines/scumm/sound.cpp
index 4d0b3fc0ee1..ec614818a1b 100644
--- a/engines/scumm/sound.cpp
+++ b/engines/scumm/sound.cpp
@@ -189,6 +189,12 @@ void Sound::triggerSound(int soundID) {
 	if (_soundCD->triggerCDSound(soundID))
 		return;
 
+	if (shouldInjectMISEAudio()) {
+		stream = _soundSE->getAudioStreamFromIndex(soundID, kSoundSETypeSFX);
+		_mixer->playStream(Audio::Mixer::kSFXSoundType, nullptr, stream, soundID);
+		return;
+	}
+
 	debugC(DEBUG_SOUND, "triggerSound #%d", soundID);
 
 	ptr = _vm->getResourceAddress(rtSound, soundID);
@@ -616,7 +622,7 @@ void Sound::startTalkSound(uint32 offset, uint32 length, int mode, Audio::SoundH
 	} else if (shouldInjectMISEAudio()) {
 		// MI1 and MI2 SE
 		if (_soundSE && !_soundsPaused && _mixer->isReady()) {
-			Audio::AudioStream *input = _soundSE->getAudioStream(
+			Audio::AudioStream *input = _soundSE->getAudioStreamFromOffset(
 				offset,
 				mode == DIGI_SND_MODE_SFX ? kSoundSETypeSFX : kSoundSETypeSpeech);
 
@@ -764,7 +770,7 @@ void Sound::startTalkSound(uint32 offset, uint32 length, int mode, Audio::SoundH
 
 			// Play remastered audio for DOTT
 			if (!input && _soundSE && _useRemasteredAudio) {
-				input = _soundSE->getAudioStream(
+				input = _soundSE->getAudioStreamFromOffset(
 					origOffset,
 					mode == DIGI_SND_MODE_SFX ? kSoundSETypeSFX : kSoundSETypeSpeech
 				);
diff --git a/engines/scumm/soundcd.cpp b/engines/scumm/soundcd.cpp
index 695dad9af95..fea3804e109 100644
--- a/engines/scumm/soundcd.cpp
+++ b/engines/scumm/soundcd.cpp
@@ -149,7 +149,7 @@ void SoundCD::playCDTrackInternal(int track, int numLoops, int startFrame, int d
 		if (_vm->_game.id == GID_LOOM) {
 			stream = makeCDDAStream("CDDA.SOU", DisposeAfterUse::YES);
 		} else if (_soundSE) {
-			stream = _soundSE->getAudioStream(track, kSoundSETypeCDAudio);
+			stream = _soundSE->getAudioStreamFromIndex(track, kSoundSETypeCDAudio);
 		}
 
 		if (!stream)
diff --git a/engines/scumm/soundse.cpp b/engines/scumm/soundse.cpp
index 3c7c70a03ea..ab7c8c0fde6 100644
--- a/engines/scumm/soundse.cpp
+++ b/engines/scumm/soundse.cpp
@@ -698,18 +698,25 @@ int32 SoundSE::getAppropriateSpeechCue(const char *msgString, const char *speech
 	return bestScoreIdx;
 }
 
-Audio::SeekableAudioStream *SoundSE::getAudioStream(uint32 offset, SoundSEType type) {
+Audio::SeekableAudioStream *SoundSE::getAudioStreamFromOffset(uint32 offset, SoundSEType type) {
+	int32 index = getSoundIndexFromOffset(offset);
+
+	if (index < 0) {
+		warning("getAudioStreamFromOffset: sound index not found for offset %d", offset);
+		return nullptr;
+	}
+
+	return getAudioStreamFromIndex(index, type);
+}
+
+Audio::SeekableAudioStream *SoundSE::getAudioStreamFromIndex(int32 index, SoundSEType type) {
 	AudioIndex *audioIndex = getAudioEntries(type);
 	AudioEntry audioEntry = {};
 
-	int32 soundIndex = (type != kSoundSETypeCDAudio) ? getSoundIndexFromOffset(offset) : (int32)offset;
-
-	if (soundIndex == -1) {
-		warning("getAudioStream: sound index not found for offset %d", offset);
+	if (index < 0)
 		return nullptr;
-	}
 
-	audioEntry = (*audioIndex)[soundIndex];
+	audioEntry = (*audioIndex)[index];
 
 	Common::SeekableReadStream *f = getAudioFile(type);
 	if (!f)
diff --git a/engines/scumm/soundse.h b/engines/scumm/soundse.h
index f3dce042425..7e9ac2b3cc3 100644
--- a/engines/scumm/soundse.h
+++ b/engines/scumm/soundse.h
@@ -53,7 +53,8 @@ public:
 	SoundSE(ScummEngine *parent, Audio::Mixer *mixer);
 	~SoundSE() = default;
 
-	Audio::SeekableAudioStream *getAudioStream(uint32 offset, SoundSEType type);
+	Audio::SeekableAudioStream *getAudioStreamFromIndex(int32 index, SoundSEType type);
+	Audio::SeekableAudioStream *getAudioStreamFromOffset(uint32 offset, SoundSEType type);
 
 	int32 handleMISESpeech(const char *msgString,
 								const char *speechFilenameSubstitution,




More information about the Scummvm-git-logs mailing list