diff options
author | Ghislain Antony Vaillant <ghisvail@gmail.com> | 2021-04-05 17:26:41 +0200 |
---|---|---|
committer | Niels Martin Hansen <nielsm@indvikleren.dk> | 2021-04-07 12:29:21 +0200 |
commit | 9725bd8dd057b499e6e79990be4e23ed31517c3c (patch) | |
tree | f96a29d432a94ff2c8be4513ab2bf6a59267755b | |
parent | 746f1ca11a18af97e4fed06e5ac1af622bf21d35 (diff) | |
download | openttd-9725bd8dd057b499e6e79990be4e23ed31517c3c.tar.xz |
Fix: Use FluidSynth default soundfont
-rw-r--r-- | src/music/fluidsynth.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/music/fluidsynth.cpp b/src/music/fluidsynth.cpp index 61686a441..acbc4a47e 100644 --- a/src/music/fluidsynth.cpp +++ b/src/music/fluidsynth.cpp @@ -77,12 +77,22 @@ const char *MusicDriver_FluidSynth::Start(const StringList ¶m) /* Load a SoundFont and reset presets (so that new instruments * get used from the SoundFont) */ if (!sfont_name) { - int i; sfont_id = FLUID_FAILED; - for (i = 0; default_sf[i]; i++) { - if (!fluid_is_soundfont(default_sf[i])) continue; - sfont_id = fluid_synth_sfload(_midi.synth, default_sf[i], 1); - if (sfont_id != FLUID_FAILED) break; + + /* Try loading the default soundfont registered with FluidSynth. */ + char *default_soundfont; + fluid_settings_dupstr(_midi.settings, "synth.default-soundfont", &default_soundfont); + if (fluid_is_soundfont(default_soundfont)) { + sfont_id = fluid_synth_sfload(_midi.synth, default_soundfont, 1); + } + + /* If no default soundfont found, try our own list. */ + if (sfont_id == FLUID_FAILED) { + for (int i = 0; default_sf[i]; i++) { + if (!fluid_is_soundfont(default_sf[i])) continue; + sfont_id = fluid_synth_sfload(_midi.synth, default_sf[i], 1); + if (sfont_id != FLUID_FAILED) break; + } } if (sfont_id == FLUID_FAILED) return "Could not open any sound font"; } else { |