foxygit / doom Log in
commit 42fa6a211c6820004e4530b67f728729a1216e28
Author:     ceski <56656010+ceski-1@users.noreply.github.com>
AuthorDate: Wed Dec 14 11:39:11 2022 -0800
Commit:     GitHub <noreply@github.com>
CommitDate: Wed Dec 14 20:39:11 2022 +0100

    win midi: Reduce messages sent on startup/reset (#1559)

    * Update reverb and chorus defaults

    * Don't send volume twice on startup
---
 src/i_winmusic.c  | 5 ++++-
 src/setup/sound.c | 4 ++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/i_winmusic.c b/src/i_winmusic.c
index 0737d47a..8d8374f4 100644
--- a/src/i_winmusic.c
+++ b/src/i_winmusic.c
@@ -122,6 +122,7 @@ typedef struct
     unsigned int elapsed_time;
     unsigned int saved_elapsed_time;
     unsigned int num_tracks;
+    boolean registered;
     boolean looping;
     boolean ff_loop;
     boolean ff_restart;
@@ -1226,7 +1227,7 @@ static void I_WIN_SetMusicVolume(int volume)

     volume_factor = sqrtf((float)volume / 120);

-    update_volume = true;
+    update_volume = song.registered;
 }

 static void I_WIN_StopSong(void)
@@ -1392,6 +1393,7 @@ static void *I_WIN_RegisterSong(void *data, int len)
     {
         song.tracks[i].iter = MIDI_IterateTrack(file, i);
     }
+    song.registered = true;

     ResetEvent(hBufferReturnEvent);
     ResetEvent(hExitEvent);
@@ -1419,6 +1421,7 @@ static void I_WIN_UnRegisterSong(void *handle)
     song.elapsed_time = 0;
     song.saved_elapsed_time = 0;
     song.num_tracks = 0;
+    song.registered = false;
     song.looping = false;
     song.ff_loop = false;
     song.ff_restart = false;
diff --git a/src/setup/sound.c b/src/setup/sound.c
index f95e8cdb..e7c08ca6 100644
--- a/src/setup/sound.c
+++ b/src/setup/sound.c
@@ -82,8 +82,8 @@ static char **midi_names;
 static int midi_num_devices;
 static int midi_index;
 char *winmm_midi_device = NULL;
-int winmm_reverb_level = 40;
-int winmm_chorus_level = 0;
+int winmm_reverb_level = -1;
+int winmm_chorus_level = -1;
 #endif

 // DOS specific variables: these are unused but should be maintained