From cbff8e09273fda913a54a0d3380bef313b55505a Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Sun, 20 Mar 2022 16:22:18 +0600 Subject: [PATCH] fluidsynth: Fallback to system soundfont if one isn't specified --- src/sound/midi_fluidsynth.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/sound/midi_fluidsynth.c b/src/sound/midi_fluidsynth.c index 23635ee1d..1af4bb2c1 100644 --- a/src/sound/midi_fluidsynth.c +++ b/src/sound/midi_fluidsynth.c @@ -5,6 +5,9 @@ # include # include # include +# ifdef __unix__ +# include +# endif # include <86box/86box.h> # include <86box/config.h> @@ -248,7 +251,12 @@ fluidsynth_init(const device_t *info) data->synth = f_new_fluid_synth(data->settings); - char *sound_font = (char *) device_get_config_string("sound_font"); + const char *sound_font = (char *) device_get_config_string("sound_font"); +# ifdef __unix__ + if (!sound_font || sound_font[0] == 0) + sound_font = (access("/usr/share/sounds/sf2/FluidR3_GM.sf2", F_OK) == 0 ? "/usr/share/sounds/sf2/FluidR3_GM.sf2" : + (access("/usr/share/soundfonts/default.sf2", F_OK) == 0 ? "/usr/share/soundfonts/default.sf2" : "")); +# endif data->sound_font = f_fluid_synth_sfload(data->synth, sound_font, 1); if (device_get_config_int("chorus")) {