aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--saga/music.cpp1
-rw-r--r--sound/midiparser.cpp20
-rw-r--r--sound/midiparser.h4
3 files changed, 19 insertions, 6 deletions
diff --git a/saga/music.cpp b/saga/music.cpp
index a4a11b4e31..9e0dad6152 100644
--- a/saga/music.cpp
+++ b/saga/music.cpp
@@ -487,6 +487,7 @@ void Music::play(uint32 resourceId, MusicFlags flags) {
parser->setTrack(0);
parser->setMidiDriver(_player);
parser->setTimerRate(_player->getBaseTempo());
+ parser->property(MidiParser::mpCenterPitchWheelOnUnload, 1);
_player->_parser = parser;
_player->setVolume(_vm->_musicVolume == 10 ? 255 : _vm->_musicVolume * 25);
diff --git a/sound/midiparser.cpp b/sound/midiparser.cpp
index 1a1b210abb..789249e742 100644
--- a/sound/midiparser.cpp
+++ b/sound/midiparser.cpp
@@ -39,6 +39,7 @@ _tempo(500000),
_psec_per_tick(5208), // 500000 / 96
_autoLoop(false),
_smartJump(false),
+_centerPitchWheelOnUnload(false),
_num_tracks(0),
_active_track(255),
_abort_parse(0) {
@@ -49,8 +50,13 @@ void MidiParser::property(int prop, int value) {
switch (prop) {
case mpAutoLoop:
_autoLoop = (value != 0);
+ break;
case mpSmartJump:
_smartJump = (value != 0);
+ break;
+ case mpCenterPitchWheelOnUnload:
+ _centerPitchWheelOnUnload = (value != 0);
+ break;
}
}
@@ -396,12 +402,16 @@ void MidiParser::unloadMusic() {
_active_track = 255;
_abort_parse = true;
- // Center the pitch wheels in preparation for the next piece of music.
- // It's not safe to do this from within allNotesOff().
+ if (_centerPitchWheelOnUnload) {
+ // Center the pitch wheels in preparation for the next piece of
+ // music. It's not safe to do this from within allNotesOff(),
+ // and might not even be safe here, so we only do it if the
+ // client has explicitly asked for it.
- if (_driver) {
- for (int i = 0; i < 16; ++i) {
- _driver->send(0x4000E0 | i); // Center the pitch wheel
+ if (_driver) {
+ for (int i = 0; i < 16; ++i) {
+ _driver->send(0x4000E0 | i);
+ }
}
}
}
diff --git a/sound/midiparser.h b/sound/midiparser.h
index d939de3131..37c1d8e753 100644
--- a/sound/midiparser.h
+++ b/sound/midiparser.h
@@ -276,6 +276,7 @@ protected:
uint32 _psec_per_tick; //!< Microseconds per tick (_tempo / _ppqn).
bool _autoLoop; //!< For lightweight clients that don't provide their own flow control.
bool _smartJump; //!< Support smart expiration of hanging notes when jumping
+ bool _centerPitchWheelOnUnload; //!< Center the pitch wheels when unloading a song
// FIXME: ? Was 32 here, Kyra tracks use 120(!!!) which seems wrong. this is a hacky
// workaround until situation is investigated.
@@ -341,7 +342,8 @@ public:
enum {
mpMalformedPitchBends = 1,
mpAutoLoop = 2,
- mpSmartJump = 3
+ mpSmartJump = 3,
+ mpCenterPitchWheelOnUnload = 4
};
public: