foxygit / doom Log in
commit ac1f0c32193abd006536eb3bfd20dc8b3a6b691a
Author:     ceski <56656010+ceski-1@users.noreply.github.com>
AuthorDate: Wed Jan 25 23:38:30 2023 -0800
Commit:     GitHub <noreply@github.com>
CommitDate: Thu Jan 26 08:38:30 2023 +0100

    win midi: Send "reset all controllers" when song loops (#1571)
---
 src/i_winmusic.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/i_winmusic.c b/src/i_winmusic.c
index a9df6247..cc4e3458 100644
--- a/src/i_winmusic.c
+++ b/src/i_winmusic.c
@@ -1081,6 +1081,10 @@ static void FillBuffer(void)
                 }
                 else if (song.looping)
                 {
+                    for (i = 0; i < MIDI_CHANNELS_PER_TRACK; ++i)
+                    {
+                        SendShortMsg(0, MIDI_EVENT_CONTROLLER, i, MIDI_CONTROLLER_RESET_ALL_CTRLS, 0);
+                    }
                     RestartTracks();
                     continue;
                 }
@@ -1407,7 +1411,7 @@ static void I_WIN_UnRegisterSong(void *handle)
 {
     if (song.tracks)
     {
-        int i;
+        unsigned int i;
         for (i = 0; i < song.num_tracks; ++i)
         {
             MIDI_FreeIterator(song.tracks[i].iter);