foxygit / doom Log in
commit 4537cf40ac55224d1676b77555dbfe193bd5bedc
Author:     Michael Day <mikeguy42@gmail.com>
AuthorDate: Thu Aug 12 23:28:02 2021 -0400
Commit:     Michael Day <mikeguy42@gmail.com>
CommitDate: Fri Aug 13 21:01:07 2021 -0400

    Introduce FluidSynth soundfont path

    Add fluidsynth_sf_path config variable.
    Set FluidSynth soundfont path with Mix_SetSoundFonts.
---
 src/i_sdlmusic.c | 9 +++++++++
 src/i_sound.c    | 2 ++
 src/m_config.c   | 6 ++++++
 3 files changed, 17 insertions(+)

diff --git a/src/i_sdlmusic.c b/src/i_sdlmusic.c
index 090990a7..8c492f54 100644
--- a/src/i_sdlmusic.c
+++ b/src/i_sdlmusic.c
@@ -56,6 +56,7 @@ static boolean sdl_was_initialized = false;
 static boolean musicpaused = false;
 static int current_music_volume;

+char *fluidsynth_sf_path = "";
 char *timidity_cfg_path = "";

 static char *temp_timidity_cfg = NULL;
@@ -208,6 +209,14 @@ static boolean I_SDL_InitMusic(void)

     RemoveTimidityConfig();

+    // When using FluidSynth, proceed to set the soundfont path via
+    // Mix_SetSoundFonts if necessary.
+
+    if (strlen(fluidsynth_sf_path) > 0 && strlen(timidity_cfg_path) == 0)
+    {
+        Mix_SetSoundFonts(fluidsynth_sf_path);
+    }
+
     // If snd_musiccmd is set, we need to call Mix_SetMusicCMD to
     // configure an external music playback program.

diff --git a/src/i_sound.c b/src/i_sound.c
index 41a1374d..29f4f695 100644
--- a/src/i_sound.c
+++ b/src/i_sound.c
@@ -83,6 +83,7 @@ extern int opl_io_port;
 // For native music module:

 extern char *music_pack_path;
+extern char *fluidsynth_sf_path;
 extern char *timidity_cfg_path;

 // DOS-specific options: These are unused but should be maintained
@@ -504,6 +505,7 @@ void I_BindSoundVariables(void)
     M_BindIntVariable("snd_pitchshift",          &snd_pitchshift);

     M_BindStringVariable("music_pack_path",      &music_pack_path);
+    M_BindStringVariable("fluidsynth_sf_path",   &fluidsynth_sf_path);
     M_BindStringVariable("timidity_cfg_path",    &timidity_cfg_path);
     M_BindStringVariable("gus_patch_path",       &gus_patch_path);
     M_BindIntVariable("gus_ram_kb",              &gus_ram_kb);
diff --git a/src/m_config.c b/src/m_config.c
index f5b3b4c6..1ad69e4d 100644
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -928,6 +928,12 @@ static default_t extra_defaults_list[] =

     CONFIG_VARIABLE_STRING(music_pack_path),

+    //!
+    // Documentation goes here.
+    //
+
+    CONFIG_VARIABLE_STRING(fluidsynth_sf_path),
+
     //!
     // Full path to a Timidity configuration file to use for MIDI
     // playback. The file will be evaluated from the directory where