summaryrefslogtreecommitdiff
path: root/src/music
diff options
context:
space:
mode:
authorNiels Martin Hansen <nielsm@indvikleren.dk>2018-03-18 16:15:14 +0100
committerMichael Lutz <michi@icosahedron.de>2018-05-01 22:29:53 +0200
commit52655b584957df0b504e51a34b1a192449048dc2 (patch)
tree2339b507b634445eba8906e5cb6bd1e05d9c2227 /src/music
parent99a39c842c8721ec3c52082399cbac5e5e0adf10 (diff)
downloadopenttd-52655b584957df0b504e51a34b1a192449048dc2.tar.xz
Change: [Win32 MIDI] Reset pitch bend range controllers on song change
Some songs (at least one in OpenMSX) use the MIDI pitch bend range controllers but don't reset these at the end. This causes all subsequent songs to sound wrong.
Diffstat (limited to 'src/music')
-rw-r--r--src/music/win32_m.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/music/win32_m.cpp b/src/music/win32_m.cpp
index bd2ed7038..edaae36fa 100644
--- a/src/music/win32_m.cpp
+++ b/src/music/win32_m.cpp
@@ -126,6 +126,19 @@ void CALLBACK TimerCallback(UINT uTimerID, UINT, DWORD_PTR dwUser, DWORD_PTR, DW
DEBUG(driver, 2, "Win32-MIDI: timer: do_start is set");
if (_midi.playing) {
midiOutReset(_midi.midi_out);
+ /* 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 unselect again */
+ TransmitChannelMsg(MIDIST_CONTROLLER | ch, MIDICT_RPN_SELECT_LO, 0x00);
+ TransmitChannelMsg(MIDICT_RPN_SELECT_HI, 0x00);
+ TransmitChannelMsg(MIDICT_DATAENTRY, 0x02);
+ TransmitChannelMsg(MIDICT_DATAENTRY_LO, 0x00);
+ TransmitChannelMsg(MIDICT_RPN_SELECT_LO, 0x7F);
+ TransmitChannelMsg(MIDICT_RPN_SELECT_HI, 0x7F);
+ }
}
_midi.current_file.MoveFrom(_midi.next_file);
std::swap(_midi.next_segment, _midi.current_segment);