From d8b2c98ca3db62fa3d4e1dbb8801c6f57a10b8bf Mon Sep 17 00:00:00 2001
From: Districh <[EMAIL REDACTED]>
Date: Fri, 24 Mar 2023 20:24:26 +0300
Subject: [PATCH] Make FluidSynth gain adjustment between 0 and 1.0 to avoid
clicks in sound and have the loudness same as other MIDI backends
(cherry-picked from commit 257ca75e850d0aa8380d6d2215e85ec28fb491d7)
(cherry-picked from commit 83a0b7533874019c0fa6dcaff42ddb8f0df62738)
---
music_fluidsynth.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/music_fluidsynth.c b/music_fluidsynth.c
index c5b2a58d..1c78bb5d 100644
--- a/music_fluidsynth.c
+++ b/music_fluidsynth.c
@@ -207,8 +207,8 @@ int fluidsynth_active(FluidSynthMidiSong *song)
void fluidsynth_setvolume(FluidSynthMidiSong *song, int volume)
{
- /* FluidSynth's default is 0.2. Make 1.2 the maximum. */
- fluidsynth.fluid_synth_set_gain(song->synth, (float) (volume * 1.2 / MIX_MAX_VOLUME));
+ /* FluidSynth's default gain is 0.2. Make 1.0 the maximum gain value to avoid sound overload. */
+ fluidsynth.fluid_synth_set_gain(song->synth, volume * 1.0f / MIX_MAX_VOLUME);
}
static void fluid_get_samples(FluidSynthMidiSong *song)