summaryrefslogtreecommitdiff
path: root/src/music
diff options
context:
space:
mode:
authorNiels Martin Hansen <nielsm@indvikleren.dk>2019-07-04 21:47:19 +0200
committerNiels Martin Hansen <nielsm@indvikleren.dk>2019-07-04 22:27:34 +0200
commit27b7c5a5fde021d0b00cd73b5fb1412fcf0431cd (patch)
treeeb7b5548351e069fbbdf3690cd7539282b711b73 /src/music
parenta4cf1c8aec984e09c2814504c0383148cae9a8e9 (diff)
downloadopenttd-27b7c5a5fde021d0b00cd73b5fb1412fcf0431cd.tar.xz
Fix: Correctly reset playback between songs in DMusic driver
Diffstat (limited to 'src/music')
-rw-r--r--src/music/dmusic.cpp32
1 files changed, 8 insertions, 24 deletions
diff --git a/src/music/dmusic.cpp b/src/music/dmusic.cpp
index 65e2d4c83..7236e89f7 100644
--- a/src/music/dmusic.cpp
+++ b/src/music/dmusic.cpp
@@ -574,27 +574,16 @@ static void TransmitNotesOff(IDirectMusicBuffer *buffer, REFERENCE_TIME block_ti
TransmitChannelMsg(_buffer, block_time + 10, MIDIST_CONTROLLER | ch, MIDICT_SUSTAINSW, 0);
TransmitChannelMsg(_buffer, block_time + 10, MIDIST_CONTROLLER | ch, MIDICT_MODE_RESETALLCTRL, 0);
}
- /* Explicitly flush buffer to make sure the note off messages are processed
- * before we send any additional control messages. */
+
+ /* Performing a GM reset stops all sound and resets all parameters. */
+ TransmitStandardSysex(_buffer, block_time + 20, MidiSysexMessage::ResetGM);
+ TransmitStandardSysex(_buffer, block_time + 30, MidiSysexMessage::RolandSetReverb);
+
+ /* Explicitly flush buffer to make sure the messages are processed,
+ * as we want sound to stop immediately. */
_port->PlayBuffer(_buffer);
_buffer->Flush();
- /* Some songs change the "Pitch bend range" registered parameter. If
- * this doesn't get reset, everything else will start sounding wrong. */
- for (int ch = 0; ch < 16; ch++) {
- /* Running status, only need status for first message
- * Select RPN 00.00, set value to 02.00, and de-select again */
- TransmitChannelMsg(_buffer, block_time + 10, MIDIST_CONTROLLER | ch, MIDICT_RPN_SELECT_LO, 0x00);
- TransmitChannelMsg(_buffer, block_time + 10, MIDICT_RPN_SELECT_HI, 0x00);
- TransmitChannelMsg(_buffer, block_time + 10, MIDICT_DATAENTRY, 0x02);
- TransmitChannelMsg(_buffer, block_time + 10, MIDICT_DATAENTRY_LO, 0x00);
- TransmitChannelMsg(_buffer, block_time + 10, MIDICT_RPN_SELECT_LO, 0x7F);
- TransmitChannelMsg(_buffer, block_time + 10, MIDICT_RPN_SELECT_HI, 0x7F);
-
- _port->PlayBuffer(_buffer);
- _buffer->Flush();
- }
-
/* Wait until message time has passed. */
Sleep(Clamp((block_time - cur_time) / MS_TO_REFTIME, 5, 1000));
}
@@ -619,11 +608,6 @@ static void MidiThreadProc()
REFERENCE_TIME cur_time;
clock->GetTime(&cur_time);
- /* Standard "Enable General MIDI" message */
- TransmitStandardSysex(_buffer, block_time + 20, MidiSysexMessage::ResetGM);
- /* Roland-specific reverb room control, used by the original game */
- TransmitStandardSysex(_buffer, block_time + 30, MidiSysexMessage::RolandSetReverb);
-
_port->PlayBuffer(_buffer);
_buffer->Flush();
@@ -666,7 +650,7 @@ static void MidiThreadProc()
_playback.do_start = false;
}
- /* Turn all notes off in case we are seeking between music titles. */
+ /* Reset playback device between songs. */
clock->GetTime(&cur_time);
TransmitNotesOff(_buffer, block_time, cur_time);