[Scummvm-git-logs] scummvm master -> 111e7efd9e923959e2cdddfbe8b43398fa0a4ffb
bluegr
noreply at scummvm.org
Thu Jan 30 09:32:49 UTC 2025
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
3a719d9e8b SCUMM: Renaming. Update the name to index dictionary only for MI speech
fe16ca9bd9 SCUMM: Simplify audio CD handling code
111e7efd9e SCUMM: Initial skeleton code for MI1SE/MI2SE ambience tracks
Commit: 3a719d9e8b83f5403a23f412b47390b29ee73553
https://github.com/scummvm/scummvm/commit/3a719d9e8b83f5403a23f412b47390b29ee73553
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-01-30T11:13:10+02:00
Commit Message:
SCUMM: Renaming. Update the name to index dictionary only for MI speech
Changed paths:
engines/scumm/soundse.cpp
engines/scumm/soundse.h
diff --git a/engines/scumm/soundse.cpp b/engines/scumm/soundse.cpp
index cbce88ed5ba..b787959f9ba 100644
--- a/engines/scumm/soundse.cpp
+++ b/engines/scumm/soundse.cpp
@@ -163,10 +163,10 @@ void SoundSE::indexXWBFile(SoundSEType type) {
Common::String name = f->readString(0, 64);
name.toLowercase();
- if (type != kSoundSETypePatch) {
+ if (type == kSoundSETypeSpeech) {
(*audioIndex)[i].name = name;
- _nameToIndex[name] = i;
- } else {
+ _nameToIndexMISpeech[name] = i;
+ } else if (type == kSoundSETypePatch) {
// Patch audio resources for MI2
// Note: We assume that patch XWB files always contain file names
@@ -190,10 +190,10 @@ void SoundSE::indexXWBFile(SoundSEType type) {
// yet, so we don't patch them.
// TODO: Process and patch music entries, once we start using
// the SE audio files for music.
- const int32 originalAudioIndex = _nameToIndex[name];
+ const int32 originalAudioIndex = _nameToIndexMISpeech[name];
if (originalAudioIndex < (int32)_speechEntries.size() && _speechEntries[originalAudioIndex].name == name) {
_speechEntries[originalAudioIndex].isPatched = true;
- _nameToIndexPatched[name] = i;
+ _nameToIndexMISpeechPatched[name] = i;
}
}
}
@@ -246,7 +246,7 @@ void SoundSE::indexSpeechXSBFile() {
if (index < (*audioIndex).size()) {
(*audioIndex)[index].name = name;
- _nameToIndex[name] = index;
+ _nameToIndexMISpeech[name] = index;
//debug("indexSpeechXSBFile: %s -> index %d", name.c_str(), index);
}
}
@@ -774,8 +774,8 @@ Audio::SeekableAudioStream *SoundSE::getAudioStreamFromIndex(int32 index, SoundS
audioEntry = (*audioIndex)[index];
// Load patched audio files, if present
- if (audioEntry.isPatched && _nameToIndexPatched.contains(audioEntry.name)) {
- int32 patchedEntry = _nameToIndexPatched[audioEntry.name];
+ if (audioEntry.isPatched && _nameToIndexMISpeechPatched.contains(audioEntry.name)) {
+ int32 patchedEntry = _nameToIndexMISpeechPatched[audioEntry.name];
type = kSoundSETypePatch;
audioIndex = getAudioEntries(type);
audioEntry = (*audioIndex)[patchedEntry];
@@ -896,7 +896,7 @@ int32 SoundSE::handleMISESpeech(const char *msgString, const char *speechFilenam
if (entryIndex >= 0 && entryIndex < (int32)_audioEntriesMI.size()) {
const AudioEntryMI *entry = &_audioEntriesMI[entryIndex];
//debug("Selected entry: %s (%s)", entry->textEnglish.c_str(), entry->speechFile.c_str());
- return _nameToIndex.contains(entry->speechFile) ? _nameToIndex[entry->speechFile] : -1;
+ return _nameToIndexMISpeech.contains(entry->speechFile) ? _nameToIndexMISpeech[entry->speechFile] : -1;
}
return -1;
diff --git a/engines/scumm/soundse.h b/engines/scumm/soundse.h
index 805da5c07bd..4cc8f0e4c8e 100644
--- a/engines/scumm/soundse.h
+++ b/engines/scumm/soundse.h
@@ -126,8 +126,8 @@ private:
OffsetToIndexMap _offsetToIndexDOTTAndFT;
NameToOffsetMap _nameToOffsetDOTTAndFT;
- NameToIndexMap _nameToIndex;
- NameToIndexMap _nameToIndexPatched;
+ NameToIndexMap _nameToIndexMISpeech;
+ NameToIndexMap _nameToIndexMISpeechPatched;
AudioIndex _musicEntries;
AudioIndex _speechEntries;
Commit: fe16ca9bd9320dea2a16f6dc005765a9b2a11efa
https://github.com/scummvm/scummvm/commit/fe16ca9bd9320dea2a16f6dc005765a9b2a11efa
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-01-30T11:13:11+02:00
Commit Message:
SCUMM: Simplify audio CD handling code
Changed paths:
engines/scumm/sound.cpp
engines/scumm/sound.h
engines/scumm/soundcd.cpp
engines/scumm/soundcd.h
diff --git a/engines/scumm/sound.cpp b/engines/scumm/sound.cpp
index 255ae5bca61..de1123ef75e 100644
--- a/engines/scumm/sound.cpp
+++ b/engines/scumm/sound.cpp
@@ -87,11 +87,12 @@ Sound::Sound(ScummEngine *parent, Audio::Mixer *mixer, bool useReplacementAudioT
// Initialize the SE sound engine for all doublefine packed games,
// except for Maniac Mansion (within DOTT), which doesn't have
// associated SE resources in the PAK file.
- if (_vm->_game.features & GF_DOUBLEFINE_PAK && _vm->_game.id != GID_MANIAC)
+ if (_vm->_game.features & GF_DOUBLEFINE_PAK && _vm->_game.id != GID_MANIAC) {
_soundSE = new SoundSE(_vm, _mixer);
- _soundCD = new SoundCD(_vm, _mixer, _soundSE, useReplacementAudioTracks);
+ _useRemasteredAudio = ConfMan.getBool("use_remastered_audio");
+ }
- _useRemasteredAudio = ConfMan.getBool("use_remastered_audio");
+ _soundCD = new SoundCD(_vm, _mixer, _soundSE, useReplacementAudioTracks);
// This timer targets every talkie game, except for LOOM CD
// which is handled differently, and except for COMI which
@@ -310,24 +311,10 @@ void Sound::triggerSound(int soundID) {
if (type == 2) {
// CD track resource
- ptr += 0x16;
if (soundID == _soundCD->_currentCDSound && _soundCD->pollCD() == 1)
return;
- int track = ptr[0];
- int loops = ptr[1];
- int start = (ptr[2] * 60 + ptr[3]) * 75 + ptr[4];
- int end = (ptr[5] * 60 + ptr[6]) * 75 + ptr[7];
-
- // Add the user-specified adjustments.
- if (_vm->_game.id == GID_MONKEY && track == 17) {
- int adjustment = ConfMan.getInt(start == 0 ? "mi1_intro_adjustment" : "mi1_outlook_adjustment");
-
- start += ((75 * adjustment) / 100);
- }
-
- _soundCD->playCDTrack(track, loops == 0xff ? -1 : loops, start, end <= start ? 0 : end - start);
- _soundCD->_currentCDSound = soundID;
+ _soundCD->playCDTrackFromSoundID(soundID);
} else {
// All other sound types are ignored
warning("Scumm::Sound::triggerSound: encountered audio resource with chunk type 'SOUN' and sound type %d", type);
diff --git a/engines/scumm/sound.h b/engines/scumm/sound.h
index 34d0957db2e..53791f3d724 100644
--- a/engines/scumm/sound.h
+++ b/engines/scumm/sound.h
@@ -154,11 +154,17 @@ public:
void startRemasteredSpeech(const char *msgString, uint16 roomNumber, uint16 actorTalking, uint16 numWaits);
// TODO: Duplicate this in Sound as well?
- bool isRolandLoom() const { return _soundCD->isRolandLoom(); }
+ bool isRolandLoom() const {
+ return _soundCD->isRolandLoom();
+ }
// CD audio wrapper methods
- int pollCD() const { return _soundCD->pollCD(); }
- void updateCD() { _soundCD->updateCD(); }
+ int pollCD() const {
+ return _soundCD->pollCD();
+ }
+ void updateCD() {
+ _soundCD->updateCD();
+ }
void stopCD() {
_soundCD->stopCD();
_soundCD->stopCDTimer();
@@ -166,11 +172,12 @@ public:
void playCDTrack(int track, int numLoops, int startFrame, int duration) {
_soundCD->playCDTrack(track, numLoops, startFrame, duration);
}
- int getCurrentCDSound() const { return _soundCD->getCurrentCDSound(); }
+ int getCurrentCDSound() const {
+ return _soundCD->getCurrentCDSound();
+ }
void restoreCDAudioAfterLoad(AudioCDManager::Status &info) {
_soundCD->restoreCDAudioAfterLoad(info);
}
-
void setupMISEAudioParams(int32 scriptNum, int32 scriptOffset) {
_soundSE->setupMISEAudioParams(scriptNum, scriptOffset);
}
diff --git a/engines/scumm/soundcd.cpp b/engines/scumm/soundcd.cpp
index fea3804e109..b7051a25027 100644
--- a/engines/scumm/soundcd.cpp
+++ b/engines/scumm/soundcd.cpp
@@ -116,6 +116,16 @@ void SoundCD::stopCDTimer() {
_vm->getTimerManager()->removeTimerProc(&cdTimerHandler);
}
+int SoundCD::playCDTrackFromSoundID(int soundId) {
+ int loops = 1;
+ int start = 0;
+ int end = 0;
+ int trackNr = getCDTrackIdFromSoundId(soundId, loops, start, end);
+ _currentCDSound = soundId;
+ playCDTrack(trackNr, loops == 0xff ? -1 : loops, start, end <= start ? 0 : end - start);
+ return trackNr;
+}
+
void SoundCD::playCDTrack(int track, int numLoops, int startFrame, int duration) {
// Reset the music timer variable at the start of a new track
_vm->VAR(_vm->VAR_MUSIC_TIMER) = 0;
@@ -192,7 +202,7 @@ AudioCDManager::Status SoundCD::getCDStatus() {
}
}
-int SoundCD::getCDTrackIdFromSoundId(int soundId, int &loops, int &start) {
+int SoundCD::getCDTrackIdFromSoundId(int soundId, int &loops, int &start, int &end) {
if (_vm->_game.id == GID_LOOM && _vm->_game.version == 4) {
loops = 0;
start = -1;
@@ -201,9 +211,18 @@ int SoundCD::getCDTrackIdFromSoundId(int soundId, int &loops, int &start) {
if (soundId != -1 && _vm->getResourceAddress(rtSound, soundId)) {
uint8 *ptr = _vm->getResourceAddress(rtSound, soundId) + 0x18;
+ int track = ptr[0];
loops = ptr[1];
start = (ptr[2] * 60 + ptr[3]) * 75 + ptr[4];
- return ptr[0];
+ end = (ptr[5] * 60 + ptr[6]) * 75 + ptr[7];
+
+ // Add the user-specified adjustments.
+ if (_vm->_game.id == GID_MONKEY && track == 17) {
+ int adjustment = ConfMan.getInt(start == 0 ? "mi1_intro_adjustment" : "mi1_outlook_adjustment");
+ start += ((75 * adjustment) / 100);
+ }
+
+ return track;
}
loops = 1;
@@ -287,55 +306,58 @@ void SoundCD::updateMusicTimer() {
_musicTimer = 277;
}
-void SoundCD::restoreAfterLoad() {
+int SoundCD::restoreAfterLoad() {
_musicTimer = 0;
_replacementTrackStartTime = 0;
int trackNr = -1;
int loops = 1;
int start = 0;
- if (_currentCDSound) {
- if (_useReplacementAudioTracks) {
- trackNr = getReplacementAudioTrack(_currentCDSound);
- } else if (_vm->_game.platform != Common::kPlatformFMTowns) {
- trackNr = getCDTrackIdFromSoundId(_currentCDSound, loops, start);
- }
+ int end = 0;
- if (trackNr != -1) {
- if (_useReplacementAudioTracks) {
- int32 now = _vm->VAR(_vm->VAR_TIMER_TOTAL);
- uint32 frame;
-
- _musicTimer = _vm->VAR(_vm->VAR_MUSIC_TIMER);
-
- // We try to resume the audio track from where it was
- // saved. The timer isn't very accurate, but it should
- // be good enough.
- //
- // NOTE: This does not seem to work at the moment, since
- // the track immediately gets restarted in the cases I
- // tried.
-
- if (_musicTimer > 0) {
- int32 ticks = TIMER_TO_TICKS(_musicTimer);
-
- _replacementTrackStartTime = now - TICKS_TO_JIFFIES(ticks);
- frame = (75 * ticks) / 10;
- } else {
- _replacementTrackStartTime = now;
- frame = 0;
- }
-
- // If the user has fiddled with the Loom overture
- // setting, the calculated position could be outside
- // the track. But it seems a warning message is as bad
- // as it gets.
-
- g_system->getAudioCDManager()->play(trackNr, 1, frame, 0, true);
- } else if (_vm->_game.platform != Common::kPlatformFMTowns) {
- g_system->getAudioCDManager()->play(trackNr, loops, start + _vm->VAR(_vm->VAR_MUSIC_TIMER), 0, true);
- }
+ if (!_currentCDSound)
+ return -1;
+
+ if (_useReplacementAudioTracks) {
+ trackNr = getReplacementAudioTrack(_currentCDSound);
+ if (trackNr == -1)
+ return -1;
+
+ int32 now = _vm->VAR(_vm->VAR_TIMER_TOTAL);
+ uint32 frame;
+
+ _musicTimer = _vm->VAR(_vm->VAR_MUSIC_TIMER);
+
+ // We try to resume the audio track from where it was
+ // saved. The timer isn't very accurate, but it should
+ // be good enough.
+ //
+ // NOTE: This does not seem to work at the moment, since
+ // the track immediately gets restarted in the cases I
+ // tried.
+
+ if (_musicTimer > 0) {
+ int32 ticks = TIMER_TO_TICKS(_musicTimer);
+
+ _replacementTrackStartTime = now - TICKS_TO_JIFFIES(ticks);
+ frame = (75 * ticks) / 10;
+ } else {
+ _replacementTrackStartTime = now;
+ frame = 0;
}
+
+ // If the user has fiddled with the Loom overture
+ // setting, the calculated position could be outside
+ // the track. But it seems a warning message is as bad
+ // as it gets.
+
+ g_system->getAudioCDManager()->play(trackNr, 1, frame, 0, true);
+ } else if (_vm->_game.platform != Common::kPlatformFMTowns) {
+ trackNr = getCDTrackIdFromSoundId(_currentCDSound, loops, start, end);
+ if (trackNr != -1)
+ g_system->getAudioCDManager()->play(trackNr, loops, start + _vm->VAR(_vm->VAR_MUSIC_TIMER), 0, true);
}
+
+ return trackNr;
}
void SoundCD::restoreCDAudioAfterLoad(AudioCDManager::Status &info) {
diff --git a/engines/scumm/soundcd.h b/engines/scumm/soundcd.h
index eb55c5a750c..6c161ccddc2 100644
--- a/engines/scumm/soundcd.h
+++ b/engines/scumm/soundcd.h
@@ -75,6 +75,7 @@ public:
void startCDTimer();
void stopCDTimer();
+ int playCDTrackFromSoundID(int soundId);
void playCDTrack(int track, int numLoops, int startFrame, int duration);
void stopCD();
int pollCD() const;
@@ -82,7 +83,7 @@ public:
AudioCDManager::Status getCDStatus();
int getCurrentCDSound() const { return _currentCDSound; }
- void restoreAfterLoad();
+ int restoreAfterLoad();
void restoreCDAudioAfterLoad(AudioCDManager::Status &info);
bool isRolandLoom() const;
@@ -90,7 +91,7 @@ public:
private:
int getReplacementAudioTrack(int soundID);
void playCDTrackInternal(int track, int numLoops, int startFrame, int duration);
- int getCDTrackIdFromSoundId(int soundId, int &loops, int &start);
+ int getCDTrackIdFromSoundId(int soundId, int &loops, int &start, int &end);
};
} // End of namespace Scumm
Commit: 111e7efd9e923959e2cdddfbe8b43398fa0a4ffb
https://github.com/scummvm/scummvm/commit/111e7efd9e923959e2cdddfbe8b43398fa0a4ffb
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2025-01-30T11:13:12+02:00
Commit Message:
SCUMM: Initial skeleton code for MI1SE/MI2SE ambience tracks
Changed paths:
engines/scumm/metaengine.cpp
engines/scumm/sound.cpp
engines/scumm/sound.h
engines/scumm/soundse.cpp
engines/scumm/soundse.h
diff --git a/engines/scumm/metaengine.cpp b/engines/scumm/metaengine.cpp
index b0cc4e9862c..f8457e81424 100644
--- a/engines/scumm/metaengine.cpp
+++ b/engines/scumm/metaengine.cpp
@@ -808,6 +808,20 @@ static const ExtraGuiOption useRemasteredAudio = {
0
};
+// TODO: Ambience sounds are disabled for now, as they require the following:
+// - WMA codec
+// - Read ambience track info from resource files
+#if 0
+static const ExtraGuiOption enableAmbienceSounds = {
+ _s("Enable ambience sounds"),
+ _s("Enable ambience sounds."),
+ "enable_ambience_sounds",
+ true,
+ 0,
+ 0
+};
+#endif
+
const ExtraGuiOptions ScummMetaEngine::getExtraGuiOptions(const Common::String &target) const {
ExtraGuiOptions options;
// Query the GUI options
@@ -839,6 +853,10 @@ const ExtraGuiOptions ScummMetaEngine::getExtraGuiOptions(const Common::String &
}
if (target.empty() || guiOptions.contains(GAMEOPTION_USE_REMASTERED_AUDIO)) {
options.push_back(useRemasteredAudio);
+#if 0
+ if (gameid == "monkey" || gameid == "monkey2")
+ options.push_back(enableAmbienceSounds);
+#endif
}
if (target.empty() || gameid == "comi") {
options.push_back(comiObjectLabelsOption);
diff --git a/engines/scumm/sound.cpp b/engines/scumm/sound.cpp
index de1123ef75e..3fb7b6e2050 100644
--- a/engines/scumm/sound.cpp
+++ b/engines/scumm/sound.cpp
@@ -90,6 +90,8 @@ Sound::Sound(ScummEngine *parent, Audio::Mixer *mixer, bool useReplacementAudioT
if (_vm->_game.features & GF_DOUBLEFINE_PAK && _vm->_game.id != GID_MANIAC) {
_soundSE = new SoundSE(_vm, _mixer);
_useRemasteredAudio = ConfMan.getBool("use_remastered_audio");
+ if (_vm->_game.id == GID_MONKEY || _vm->_game.id == GID_MONKEY2)
+ _enableAmbienceSounds = ConfMan.getBool("enable_ambience_sounds");
}
_soundCD = new SoundCD(_vm, _mixer, _soundSE, useReplacementAudioTracks);
@@ -103,6 +105,9 @@ Sound::Sound(ScummEngine *parent, Audio::Mixer *mixer, bool useReplacementAudioT
}
Sound::~Sound() {
+ if (_enableAmbienceSounds)
+ _soundSE->stopAmbience();
+
free(_offsetTable);
delete _talkChannelHandle;
delete _soundSE;
@@ -314,7 +319,11 @@ void Sound::triggerSound(int soundID) {
if (soundID == _soundCD->_currentCDSound && _soundCD->pollCD() == 1)
return;
- _soundCD->playCDTrackFromSoundID(soundID);
+ int track = _soundCD->playCDTrackFromSoundID(soundID);
+
+ if (_vm->_game.id == GID_MONKEY && _enableAmbienceSounds) {
+ _soundSE->startAmbience(track);
+ }
} else {
// All other sound types are ignored
warning("Scumm::Sound::triggerSound: encountered audio resource with chunk type 'SOUN' and sound type %d", type);
@@ -928,6 +937,8 @@ void Sound::stopSound(int sound) {
int i;
_soundCD->stopCDSound(sound);
+ if (_enableAmbienceSounds)
+ _soundSE->stopAmbience();
if (_vm->_game.version < 7)
_mixer->stopID(sound);
@@ -950,6 +961,8 @@ void Sound::stopSound(int sound) {
void Sound::stopAllSounds() {
_soundCD->stopAllCDSounds();
+ if (_enableAmbienceSounds)
+ _soundSE->stopAmbience();
// Clear the (secondary) sound queue
_lastSound = 0;
@@ -1220,7 +1233,9 @@ void Sound::saveLoadWithSerializer(Common::Serializer &s) {
}
void Sound::restoreAfterLoad() {
- _soundCD->restoreAfterLoad();
+ int track = _soundCD->restoreAfterLoad();
+ if (_enableAmbienceSounds && track >= 0)
+ _soundSE->startAmbience(track);
}
bool Sound::isAudioDisabled() {
diff --git a/engines/scumm/sound.h b/engines/scumm/sound.h
index 53791f3d724..46dda84541c 100644
--- a/engines/scumm/sound.h
+++ b/engines/scumm/sound.h
@@ -102,6 +102,7 @@ protected:
SoundCD *_soundCD = nullptr;
SoundSE *_soundSE = nullptr;
bool _useRemasteredAudio = false;
+ bool _enableAmbienceSounds = false;
public:
Audio::SoundHandle *_talkChannelHandle; // Handle of mixer channel actor is talking on
diff --git a/engines/scumm/soundse.cpp b/engines/scumm/soundse.cpp
index b787959f9ba..cb0b61d57fe 100644
--- a/engines/scumm/soundse.cpp
+++ b/engines/scumm/soundse.cpp
@@ -902,4 +902,31 @@ int32 SoundSE::handleMISESpeech(const char *msgString, const char *speechFilenam
return -1;
}
+int32 SoundSE::getAmbienceTrack(int32 musicTrack) {
+#if 0
+ // TODO: Read ambience tracks from game resource files
+ if (musicTrack == 8)
+ return 18; // SCUMM Bar
+ else if (musicTrack == 22)
+ return 2; // Docks
+#endif
+ return -1;
+}
+
+void SoundSE::startAmbience(int32 musicTrack) {
+ int32 ambienceTrack = getAmbienceTrack(musicTrack);
+ if (ambienceTrack >= 0) {
+ stopAmbience();
+ Audio::SeekableAudioStream *ambienceStream = getAudioStreamFromIndex(ambienceTrack, kSoundSETypeAmbience);
+ if (!ambienceStream)
+ return;
+ _mixer->playStream(Audio::Mixer::kMusicSoundType, &_ambienceHandle,
+ Audio::makeLoopingAudioStream(ambienceStream, 0, 0, 0));
+ }
+}
+
+void SoundSE::stopAmbience() {
+ _mixer->stopHandle(_ambienceHandle);
+}
+
} // End of namespace Scumm
diff --git a/engines/scumm/soundse.h b/engines/scumm/soundse.h
index 4cc8f0e4c8e..5879be30efa 100644
--- a/engines/scumm/soundse.h
+++ b/engines/scumm/soundse.h
@@ -68,6 +68,9 @@ public:
_currentScriptOffsetSavedForSpeechMI = scriptOffset;
}
+ void startAmbience(int32 musicTrack);
+ void stopAmbience();
+
private:
enum AudioCodec {
kXWBCodecPCM = 0,
@@ -143,6 +146,8 @@ private:
int32 _currentScriptSavedForSpeechMI = 0;
int32 _currentScriptOffsetSavedForSpeechMI = 0;
+ Audio::SoundHandle _ambienceHandle;
+
int32 getSoundIndexFromOffset(uint32 offset);
int32 getAppropriateSpeechCue(const char *msgString,
const char *speechFilenameSubstitution,
@@ -167,6 +172,7 @@ private:
Common::SeekableReadStream *getAudioFile(const Common::String &filename);
Common::SeekableReadStream *getAudioFile(SoundSEType type);
AudioIndex *getAudioEntries(SoundSEType type);
+ int32 getAmbienceTrack(int32 musicTrack);
Audio::SeekableAudioStream *createSoundStream(Common::SeekableSubReadStream *stream, AudioEntry entry, DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES);
};
More information about the Scummvm-git-logs
mailing list