commit 1b0c89ea5ec365b6230b707562754348190ae8ba
Author: ceski <56656010+ceski-1@users.noreply.github.com>
AuthorDate: Tue May 16 10:03:46 2023 -0700
Commit: ceski <56656010+ceski-1@users.noreply.github.com>
CommitDate: Tue May 16 10:03:46 2023 -0700
Limit max channel volume
---
src/i_winmusic.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/i_winmusic.c b/src/i_winmusic.c
index 446bf538..7e1c549c 100644
--- a/src/i_winmusic.c
+++ b/src/i_winmusic.c
@@ -309,9 +309,18 @@ static void UpdateTempo(unsigned int delta_time, const midi_event_t *event)
static void SendManualVolumeMsg(unsigned int delta_time, byte channel,
byte volume)
{
- const byte scaled_volume = volume * volume_factor + 0.5f;
+ unsigned int scaled_volume;
+
+ scaled_volume = volume * volume_factor + 0.5f;
+
+ if (scaled_volume > 127)
+ {
+ scaled_volume = 127;
+ }
+
SendShortMsg(delta_time, MIDI_EVENT_CONTROLLER, channel,
MIDI_CONTROLLER_VOLUME_MSB, scaled_volume);
+
channel_volume[channel] = volume;
}