From 6d2e93254fcea18ea37c6eb21f9ba116084172d1 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Tue, 29 Dec 2015 17:14:13 -0600 Subject: [PATCH] Fix CreateSMF's SysEx writing - It was wrong before. It might still be wrong, but at least it doesn't look obviously wrong anymore. --- src/sound/music_midistream.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/sound/music_midistream.cpp b/src/sound/music_midistream.cpp index 37616b9a6..064606d0f 100644 --- a/src/sound/music_midistream.cpp +++ b/src/sound/music_midistream.cpp @@ -1196,9 +1196,15 @@ void MIDIStreamer::CreateSMF(TArray &file, int looplimit) len--; file.Push(MIDI_SYSEX); WriteVarLen(file, len); - memcpy(&file[file.Reserve(len - 1)], bytes, len); - running_status = 255; + memcpy(&file[file.Reserve(len)], bytes + 1, len); } + else + { + file.Push(MIDI_SYSEXEND); + WriteVarLen(file, len); + memcpy(&file[file.Reserve(len)], bytes, len); + } + running_status = 255; } else if (MEVT_EVENTTYPE(event[2]) == 0) {