shithub: choc

Download patch

ref: 85bcd1c917864673aa86cc14921e0ac0f209da9a
parent: f447ae17ddefc64f2bc803b5c3c81dceb7b59c68
parent: 31bb2c78accf62f89aad09d3be1680bb0ff09012
author: Simon Howard <[email protected]>
date: Tue Aug 24 10:36:35 EDT 2021

Merge pull request #1387 from mikeday0/fluid_set_sf_path

Set soundfont path directly from Chocolate

--- a/src/i_sdlmusic.c
+++ b/src/i_sdlmusic.c
@@ -56,6 +56,7 @@
 static boolean musicpaused = false;
 static int current_music_volume;
 
+char *fluidsynth_sf_path = "";
 char *timidity_cfg_path = "";
 
 static char *temp_timidity_cfg = NULL;
@@ -207,6 +208,14 @@
     // file can be removed.
 
     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.
--- a/src/i_sound.c
+++ b/src/i_sound.c
@@ -83,6 +83,7 @@
 // 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 @@
     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);
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -929,6 +929,12 @@
     CONFIG_VARIABLE_STRING(music_pack_path),
 
     //!
+    // Full path to a soundfont file to use with FluidSynth MIDI playback.
+    //
+
+    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
     // it is evaluated, so there is no need to add "dir" commands
--- a/src/setup/sound.c
+++ b/src/setup/sound.c
@@ -42,6 +42,7 @@
 };
 
 static const char *cfg_extension[] = { "cfg", NULL };
+static const char *sf_extension[] = { "sf2", "sf3", NULL };
 
 // Config file variables:
 
@@ -65,6 +66,7 @@
 
 static char *music_pack_path = NULL;
 static char *timidity_cfg_path = NULL;
+static char *fluidsynth_sf_path = NULL;
 static char *gus_patch_path = NULL;
 static int gus_ram_kb = 1024;
 
@@ -195,6 +197,12 @@
                 TXT_NewFileSelector(&timidity_cfg_path, 34,
                                     "Select Timidity config file",
                                     cfg_extension),
+                TXT_NewStrut(4, 0),
+                TXT_NewLabel("FluidSynth soundfont file: "),
+                TXT_NewStrut(4, 0),
+                TXT_NewFileSelector(&fluidsynth_sf_path, 34,
+                                    "Select FluidSynth soundfont file",
+                                    sf_extension),
                 NULL)),
         NULL);
 }
@@ -215,6 +223,7 @@
     M_BindStringVariable("gus_patch_path",        &gus_patch_path);
     M_BindStringVariable("music_pack_path",     &music_pack_path);
     M_BindStringVariable("timidity_cfg_path",     &timidity_cfg_path);
+    M_BindStringVariable("fluidsynth_sf_path",    &fluidsynth_sf_path);
 
     M_BindIntVariable("snd_sbport",               &snd_sbport);
     M_BindIntVariable("snd_sbirq",                &snd_sbirq);