aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/scumm/imuse_digi/dimuse.h4
-rw-r--r--engines/scumm/imuse_digi/dimuse_music.cpp14
-rw-r--r--engines/scumm/imuse_digi/dimuse_script.cpp15
-rw-r--r--engines/scumm/imuse_digi/dimuse_track.cpp24
4 files changed, 44 insertions, 13 deletions
diff --git a/engines/scumm/imuse_digi/dimuse.h b/engines/scumm/imuse_digi/dimuse.h
index 6abdb80cf7..8eebeb9404 100644
--- a/engines/scumm/imuse_digi/dimuse.h
+++ b/engines/scumm/imuse_digi/dimuse.h
@@ -141,7 +141,7 @@ private:
void callback();
void switchToNextRegion(Track *track);
int allocSlot(int priority);
- void startSound(int soundId, const char *soundName, int soundType, int volGroupId, Audio::AudioStream *input, int hookId, int volume, int priority);
+ void startSound(int soundId, const char *soundName, int soundType, int volGroupId, Audio::AudioStream *input, int hookId, int volume, int priority, Track *otherTrack);
void selectVolumeGroup(int soundId, int volGroupId);
int32 getPosInMs(int soundId);
@@ -149,6 +149,7 @@ private:
int getSoundIdByName(const char *soundName);
void fadeOutMusic(int fadeDelay);
+ void fadeOutMusicAndStartNew(int fadeDelay, const char *filename, int soundId);
void setHookIdForMusic(int hookId);
Track *cloneToFadeOutTrack(Track *track, int fadeDelay);
@@ -177,6 +178,7 @@ public:
void startVoice(int soundId, const char *soundName);
void startMusic(int soundId, int volume);
void startMusic(const char *soundName, int soundId, int hookId, int volume);
+ void startMusicWithOtherPos(const char *soundName, int soundId, int hookId, int volume, Track *otherTrack);
void startSfx(int soundId, int priority);
void startSound(int sound)
{ error("IMuseDigital::startSound(int) should be never called"); }
diff --git a/engines/scumm/imuse_digi/dimuse_music.cpp b/engines/scumm/imuse_digi/dimuse_music.cpp
index db33f4a355..08c7fe6ae0 100644
--- a/engines/scumm/imuse_digi/dimuse_music.cpp
+++ b/engines/scumm/imuse_digi/dimuse_music.cpp
@@ -167,8 +167,10 @@ void IMuseDigital::playDigMusic(const char *songName, const imuseDigTable *table
}
}
- if (!songName)
+ if (!songName) {
fadeOutMusic(120);
+ return;
+ }
switch (table->transitionType) {
case 0:
@@ -184,8 +186,7 @@ void IMuseDigital::playDigMusic(const char *songName, const imuseDigTable *table
_stopingSequence = true;
if ((!sequence) && (table->attribPos != 0) &&
(table->attribPos == _digStateMusicTable[_curMusicState].attribPos)) {
- fadeOutMusic(108);
- startMusic(table->filename, table->soundId, 0, 127);
+ fadeOutMusicAndStartNew(108, table->filename, table->soundId);
} else {
fadeOutMusic(108);
startMusic(table->filename, table->soundId, hookId, 127);
@@ -291,8 +292,10 @@ void IMuseDigital::playComiMusic(const char *songName, const imuseComiTable *tab
}
}
- if (!songName)
+ if (!songName) {
fadeOutMusic(120);
+ return;
+ }
switch (table->transitionType) {
case 0:
@@ -323,8 +326,7 @@ void IMuseDigital::playComiMusic(const char *songName, const imuseComiTable *tab
_stopingSequence = true;
if ((!sequence) && (table->attribPos != 0) &&
(table->attribPos == _comiStateMusicTable[_curMusicState].attribPos)) {
- fadeOutMusic(table->fadeOutDelay);
- startMusic(table->filename, table->soundId, 0, 127);
+ fadeOutMusicAndStartNew(table->fadeOutDelay, table->filename, table->soundId);
} else if (table->transitionType == 12) {
fadeOutMusic(table->fadeOutDelay);
startMusic(table->filename, table->soundId, table->hookId, 127);
diff --git a/engines/scumm/imuse_digi/dimuse_script.cpp b/engines/scumm/imuse_digi/dimuse_script.cpp
index 7cb61b347e..23c49d6c68 100644
--- a/engines/scumm/imuse_digi/dimuse_script.cpp
+++ b/engines/scumm/imuse_digi/dimuse_script.cpp
@@ -226,27 +226,32 @@ void IMuseDigital::refreshScripts() {
void IMuseDigital::startVoice(int soundId, Audio::AudioStream *input) {
debug(5, "startVoiceStream(%d)", soundId);
- startSound(soundId, "", 0, IMUSE_VOLGRP_VOICE, input, 0, 127, 127);
+ startSound(soundId, "", 0, IMUSE_VOLGRP_VOICE, input, 0, 127, 127, NULL);
}
void IMuseDigital::startVoice(int soundId, const char *soundName) {
debug(5, "startVoiceBundle(%s)", soundName);
- startSound(soundId, soundName, IMUSE_BUNDLE, IMUSE_VOLGRP_VOICE, NULL, 0, 127, 127);
+ startSound(soundId, soundName, IMUSE_BUNDLE, IMUSE_VOLGRP_VOICE, NULL, 0, 127, 127, NULL);
}
void IMuseDigital::startMusic(int soundId, int volume) {
debug(5, "startMusicResource(%d)", soundId);
- startSound(soundId, "", IMUSE_RESOURCE, IMUSE_VOLGRP_MUSIC, NULL, 0, volume, 126);
+ startSound(soundId, "", IMUSE_RESOURCE, IMUSE_VOLGRP_MUSIC, NULL, 0, volume, 126, NULL);
}
void IMuseDigital::startMusic(const char *soundName, int soundId, int hookId, int volume) {
debug(5, "startMusicBundle(%s)", soundName);
- startSound(soundId, soundName, IMUSE_BUNDLE, IMUSE_VOLGRP_MUSIC, NULL, hookId, volume, 126);
+ startSound(soundId, soundName, IMUSE_BUNDLE, IMUSE_VOLGRP_MUSIC, NULL, hookId, volume, 126, NULL);
+}
+
+void IMuseDigital::startMusicWithOtherPos(const char *soundName, int soundId, int hookId, int volume, Track *otherTrack) {
+ debug(5, "startMusicWithOtherPos(%s)", soundName);
+ startSound(soundId, soundName, IMUSE_BUNDLE, IMUSE_VOLGRP_MUSIC, NULL, hookId, volume, 126, otherTrack);
}
void IMuseDigital::startSfx(int soundId, int priority) {
debug(5, "startSfx(%d)", soundId);
- startSound(soundId, "", IMUSE_RESOURCE, IMUSE_VOLGRP_SFX, NULL, 0, 127, priority);
+ startSound(soundId, "", IMUSE_RESOURCE, IMUSE_VOLGRP_SFX, NULL, 0, 127, priority, NULL);
}
void IMuseDigital::getLipSync(int soundId, int syncId, int32 msPos, int32 &width, int32 &height) {
diff --git a/engines/scumm/imuse_digi/dimuse_track.cpp b/engines/scumm/imuse_digi/dimuse_track.cpp
index 7421244662..d1e20c5f9c 100644
--- a/engines/scumm/imuse_digi/dimuse_track.cpp
+++ b/engines/scumm/imuse_digi/dimuse_track.cpp
@@ -80,7 +80,7 @@ int IMuseDigital::allocSlot(int priority) {
return trackId;
}
-void IMuseDigital::startSound(int soundId, const char *soundName, int soundType, int volGroupId, Audio::AudioStream *input, int hookId, int volume, int priority) {
+void IMuseDigital::startSound(int soundId, const char *soundName, int soundType, int volGroupId, Audio::AudioStream *input, int hookId, int volume, int priority, Track *otherTrack) {
Common::StackLock lock(_mutex, "IMuseDigital::startSound()");
debug(5, "IMuseDigital::startSound(%d)", soundId);
@@ -153,6 +153,13 @@ void IMuseDigital::startSound(int soundId, const char *soundName, int soundType,
track->mixerFlags |= kFlagLittleEndian;
#endif
+ if (otherTrack && otherTrack->used && !otherTrack->toBeRemoved) {
+ track->curRegion = otherTrack->curRegion;
+ track->regionOffset = otherTrack->regionOffset;
+ track->dataOffset = otherTrack->dataOffset;
+ track->dataMod12Bit = otherTrack->dataMod12Bit;
+ }
+
track->stream = Audio::makeAppendableAudioStream(freq, makeMixerFlags(track->mixerFlags));
_mixer->playInputStream(track->getType(), &track->mixChanHandle, track->stream, -1, track->getVol(), track->getPan());
}
@@ -267,6 +274,20 @@ void IMuseDigital::setFade(int soundId, int destVolume, int delay60HzTicks) {
}
}
+void IMuseDigital::fadeOutMusicAndStartNew(int fadeDelay, const char *filename, int soundId) {
+ Common::StackLock lock(_mutex, "IMuseDigital::fadeOutMusicAndStartNew()");
+ debug(5, "IMuseDigital::fadeOutMusicAndStartNew");
+
+ for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
+ Track *track = _track[l];
+ if (track->used && !track->toBeRemoved && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) {
+ startMusicWithOtherPos(filename, soundId, 0, 127, track);
+ cloneToFadeOutTrack(track, fadeDelay);
+ flushTrack(track);
+ }
+ }
+}
+
void IMuseDigital::fadeOutMusic(int fadeDelay) {
Common::StackLock lock(_mutex, "IMuseDigital::fadeOutMusic()");
debug(5, "IMuseDigital::fadeOutMusic");
@@ -276,6 +297,7 @@ void IMuseDigital::fadeOutMusic(int fadeDelay) {
if (track->used && !track->toBeRemoved && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) {
cloneToFadeOutTrack(track, fadeDelay);
flushTrack(track);
+ break;
}
}
}