[Scummvm-git-logs] scummvm master -> cdd2d58361d624dcb91b69293269877bb3e6f6db
sev-
sev at scummvm.org
Thu Aug 20 22:03:14 UTC 2020
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:
2d87adbed4 GROOVIE: Fix music fade-out behavior
4ed78ef114 GROOVIE: Fix music when loading game
cdd2d58361 GROOVIE: Fix starting background music
Commit: 2d87adbed470ac46cc15fa54e898a52fc9066abf
https://github.com/scummvm/scummvm/commit/2d87adbed470ac46cc15fa54e898a52fc9066abf
Author: NMIError (crampen at gmail.com)
Date: 2020-08-21T00:03:09+02:00
Commit Message:
GROOVIE: Fix music fade-out behavior
When fading out a music track, the original interpreter would keep playing the
track at volume 0. ScummVM would instead stop playing the track, which would
cause the background music track to start playing, while there would be no
music in the original interpreter. Also, when starting playback of a new track,
the original interpreter would restore the volume first, then start playback of
the new track, causing a short part of the old track to be played before the
new track starts. ScummVM would turn the volume back up, but not actually apply
this to the MIDI device, causing new tracks to sometimes play at volume 0.
This change fixes these issues. After fading out, actual playback on the MIDI
device is stopped, but the state of the music player keeps indicating that
music is playing. This prevents the background music from starting. Because
playback is actually stopped, the original interpreter issue of playing a short
bit of the old track when the new track starts is prevented. When resetting
volume when starting a new track, the new volume is now applied to the MIDI
device, which fixes the issue of the new track playing at volume 0.
Changed paths:
engines/groovie/music.cpp
engines/groovie/music.h
diff --git a/engines/groovie/music.cpp b/engines/groovie/music.cpp
index 30d2008bf6..8985c7e719 100644
--- a/engines/groovie/music.cpp
+++ b/engines/groovie/music.cpp
@@ -58,6 +58,7 @@ void MusicPlayer::playSong(uint32 fileref) {
// Set the volumes
_fadingEndVolume = 100;
_gameVolume = 100;
+ updateVolume();
// Play the referenced file once
play(fileref, false);
@@ -203,7 +204,15 @@ void MusicPlayer::applyFading() {
// If we were fading to 0, stop the playback and restore the volume
if (_fadingEndVolume == 0) {
debugC(1, kDebugMIDI, "Groovie::Music: Faded to zero: end of song. _fadingEndVolume set to 100");
- unload();
+ // WORKAROUND The original interpreter would keep playing a track
+ // at volume 0 after it has faded out. When a new track was
+ // started, it would restore the volume first and a short part of
+ // the old track would be heard before the new track would start.
+ // To prevent this, playback is actually stopped after fading out,
+ // but _isPlaying remains true. This keeps the original
+ // interpreter behavior of not starting the background music, but
+ // it prevents the issue when starting playback of a new track.
+ unload(false);
}
}
@@ -226,11 +235,12 @@ void MusicPlayer::onTimer(void *refCon) {
music->onTimerInternal();
}
-void MusicPlayer::unload() {
+void MusicPlayer::unload(bool updateState) {
debugC(1, kDebugMIDI, "Groovie::Music: Stopping the playback");
- // Set the new state
- _isPlaying = false;
+ if (updateState)
+ // Set the new state
+ _isPlaying = false;
}
void MusicPlayer::playCreditsIOS() {
@@ -357,8 +367,8 @@ void MusicPlayerMidi::updateVolume() {
}
}
-void MusicPlayerMidi::unload() {
- MusicPlayer::unload();
+void MusicPlayerMidi::unload(bool updateState) {
+ MusicPlayer::unload(updateState);
// Unload the parser data
if (_midiParser)
@@ -503,8 +513,8 @@ bool MusicPlayerXMI::load(uint32 fileref, bool loop) {
return loadParser(file, loop);
}
-void MusicPlayerXMI::unload() {
- MusicPlayerMidi::unload();
+void MusicPlayerXMI::unload(bool updateState) {
+ MusicPlayerMidi::unload(updateState);
if (_milesMidiDriver) {
_milesMidiDriver->deinitSource(0);
}
@@ -659,8 +669,8 @@ void MusicPlayerIOS::updateVolume() {
_vm->_system->getMixer()->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, _userVolume * _gameVolume / 100);
}
-void MusicPlayerIOS::unload() {
- MusicPlayer::unload();
+void MusicPlayerIOS::unload(bool updateState) {
+ MusicPlayer::unload(updateState);
_vm->_system->getMixer()->stopHandle(_handle);
}
diff --git a/engines/groovie/music.h b/engines/groovie/music.h
index d36c52867f..fd12b93f1a 100644
--- a/engines/groovie/music.h
+++ b/engines/groovie/music.h
@@ -102,7 +102,7 @@ protected:
// These are specific for each type of music
virtual void updateVolume() = 0;
virtual bool load(uint32 fileref, bool loop) = 0;
- virtual void unload();
+ virtual void unload(bool updateState = true);
};
class MusicPlayerMidi : public MusicPlayer, public MidiDriver_BASE {
@@ -130,7 +130,7 @@ protected:
void onTimerInternal() override;
void updateVolume() override;
- void unload() override;
+ void unload(bool updateState = true) override;
void endTrack();
bool loadParser(Common::SeekableReadStream *stream, bool loop);
@@ -153,7 +153,7 @@ public:
protected:
void updateVolume() override;
bool load(uint32 fileref, bool loop) override;
- void unload() override;
+ void unload(bool updateState = true) override;
private:
// Output music type
@@ -189,7 +189,7 @@ public:
protected:
void updateVolume() override;
bool load(uint32 fileref, bool loop) override;
- void unload() override;
+ void unload(bool updateState = true) override;
private:
Audio::SoundHandle _handle;
Commit: 4ed78ef11493202d99ab15a14fe5510017fbd3d6
https://github.com/scummvm/scummvm/commit/4ed78ef11493202d99ab15a14fe5510017fbd3d6
Author: NMIError (crampen at gmail.com)
Date: 2020-08-21T00:03:09+02:00
Commit Message:
GROOVIE: Fix music when loading game
When loading a savegame, the current background music would play for a few
seconds before the game would set the music for the room that just loaded.
This change stops the music when loading a savegame to prevent this.
Changed paths:
engines/groovie/music.cpp
engines/groovie/music.h
engines/groovie/script.cpp
diff --git a/engines/groovie/music.cpp b/engines/groovie/music.cpp
index 8985c7e719..660d90bcd9 100644
--- a/engines/groovie/music.cpp
+++ b/engines/groovie/music.cpp
@@ -185,6 +185,11 @@ bool MusicPlayer::play(uint32 fileref, bool loop) {
return load(fileref, loop);
}
+void MusicPlayer::stop() {
+ _backgroundFileRef = 0;
+ unload();
+}
+
void MusicPlayer::applyFading() {
debugC(6, kDebugMIDI, "Groovie::Music: applyFading() _fadingStartTime = %d, _fadingDuration = %d, _fadingStartVolume = %d, _fadingEndVolume = %d", _fadingStartTime, _fadingDuration, _fadingStartVolume, _fadingEndVolume);
Common::StackLock lock(_mutex);
diff --git a/engines/groovie/music.h b/engines/groovie/music.h
index fd12b93f1a..744b5bbff1 100644
--- a/engines/groovie/music.h
+++ b/engines/groovie/music.h
@@ -41,6 +41,9 @@ public:
virtual ~MusicPlayer();
void playSong(uint32 fileref);
+ // Stops all music playback. Clears the current
+ // background song.
+ void stop();
void setBackgroundSong(uint32 fileref);
void playCD(uint8 track);
void startBackground();
diff --git a/engines/groovie/script.cpp b/engines/groovie/script.cpp
index c8ef6da802..db2ca8ad8e 100644
--- a/engines/groovie/script.cpp
+++ b/engines/groovie/script.cpp
@@ -445,6 +445,8 @@ bool Script::hotspot(Common::Rect rect, uint16 address, uint8 cursor) {
}
void Script::loadgame(uint slot) {
+ _vm->_musicPlayer->stop();
+
Common::InSaveFile *file = SaveLoad::openForLoading(ConfMan.getActiveDomainName(), slot);
// Loading the variables. It is endian safe because they're byte variables
Commit: cdd2d58361d624dcb91b69293269877bb3e6f6db
https://github.com/scummvm/scummvm/commit/cdd2d58361d624dcb91b69293269877bb3e6f6db
Author: NMIError (crampen at gmail.com)
Date: 2020-08-21T00:03:09+02:00
Commit Message:
GROOVIE: Fix starting background music
The check to see if background music should be started was implemented as part
of the input processing. As a result, background music would not start if the
game was not getting any input. F.e. on the main menu after starting the game,
if you let the music play until it finishes without doing anything, the game
will go silent. Only after moving the mouse will the background music track
start. The original interpreter starts the background music without needing
user input.
I've fixed this by moving the check to start background music to the timer
loop of the MusicPlayer. I've added a check to prevent background music from
starting while the game is not accepting input.
Changed paths:
engines/groovie/groovie.h
engines/groovie/music.cpp
engines/groovie/script.cpp
diff --git a/engines/groovie/groovie.h b/engines/groovie/groovie.h
index c17ceb2445..90696c5758 100644
--- a/engines/groovie/groovie.h
+++ b/engines/groovie/groovie.h
@@ -111,6 +111,7 @@ protected:
public:
void waitForInput();
+ bool isWaitingForInput() { return _waitingForInput; }
Graphics::PixelFormat _pixelFormat;
bool _spookyMode;
diff --git a/engines/groovie/music.cpp b/engines/groovie/music.cpp
index 660d90bcd9..55e5668306 100644
--- a/engines/groovie/music.cpp
+++ b/engines/groovie/music.cpp
@@ -236,6 +236,10 @@ void MusicPlayer::onTimer(void *refCon) {
music->applyFading();
}
+ // If the game is accepting user input, start the background music if necessary
+ if (music->_vm->isWaitingForInput())
+ music->startBackground();
+
// Handle internal timed events
music->onTimerInternal();
}
diff --git a/engines/groovie/script.cpp b/engines/groovie/script.cpp
index db2ca8ad8e..9a5d837233 100644
--- a/engines/groovie/script.cpp
+++ b/engines/groovie/script.cpp
@@ -768,8 +768,6 @@ void Script::o_inputloopstart() { //0x0B
// Save the current pressed character for the whole loop
_kbdChar = _eventKbdChar;
_eventKbdChar = 0;
-
- _vm->_musicPlayer->startBackground();
}
void Script::o_keyboardaction() {
More information about the Scummvm-git-logs
mailing list