summaryrefslogtreecommitdiff
path: root/src/music
diff options
context:
space:
mode:
authorNikolas Nyby <nikolas@gnu.org>2019-02-08 19:43:08 -0500
committerNiels Martin Hansen <nielsm@indvikleren.dk>2019-02-21 10:08:07 +0100
commit8a6e03c4d27f04538b98d2ccb6acb4b86f09c9ed (patch)
tree7f4c670b21394f9b28eccebc58bde65b20e4c75e /src/music
parent6733b713009622b8a416227fe4cb0b754e8cb855 (diff)
downloadopenttd-8a6e03c4d27f04538b98d2ccb6acb4b86f09c9ed.tar.xz
Fix #7189: Fluidsynth volume gain too high
Diffstat (limited to 'src/music')
-rw-r--r--src/music/fluidsynth.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/music/fluidsynth.cpp b/src/music/fluidsynth.cpp
index d1088f4bc..6baeb899b 100644
--- a/src/music/fluidsynth.cpp
+++ b/src/music/fluidsynth.cpp
@@ -149,7 +149,11 @@ bool MusicDriver_FluidSynth::IsSongPlaying()
void MusicDriver_FluidSynth::SetVolume(byte vol)
{
/* Allowed range of synth.gain is 0.0 to 10.0 */
- if (fluid_settings_setnum(_midi.settings, "synth.gain", 1.0 * vol / 128.0) != 1) {
+ /* fluidsynth's default gain is 0.2, so use this as "full
+ * volume". Set gain using OpenTTD's volume, as a number between 0
+ * and 0.2. */
+ double gain = (1.0 * vol) / (128.0 * 5.0);
+ if (fluid_settings_setnum(_midi.settings, "synth.gain", gain) != 1) {
DEBUG(driver, 0, "Could not set volume");
}
}