commit 9e93b674224f57633f20a809f849e5f8682b8150
Author: Michael Day <contact@michaelcday.com>
AuthorDate: Mon Mar 13 21:19:22 2023 -0400
Commit: Michael Day <contact@michaelcday.com>
CommitDate: Tue Mar 21 13:56:58 2023 -0400
Add FluidSynth config variables
---
src/i_flmusic.c | 52 ++++++++++++++++++++++++++------------
src/i_sdlmusic.c | 1 -
src/i_sound.c | 20 ++++++++++++---
src/i_sound.h | 18 ++++++++++++--
src/m_config.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
src/setup/sound.c | 34 ++++++++++++++++++++++---
6 files changed, 171 insertions(+), 28 deletions(-)
diff --git a/src/i_flmusic.c b/src/i_flmusic.c
index cd43bd04..443507be 100644
--- a/src/i_flmusic.c
+++ b/src/i_flmusic.c
@@ -45,8 +45,17 @@ typedef fluid_long_long_t fluid_int_t;
#include "z_zone.h"
#include "i_glob.h"
-boolean mus_chorus = true;
-boolean mus_reverb = true;
+char *fsynth_sf_path = "";
+int fsynth_chorus_active = 1;
+float fsynth_chorus_depth = 5.0;
+float fsynth_chorus_level = 0.35;
+int fsynth_chorus_nr = 3;
+float fsynth_chorus_speed = 0.3;
+int fsynth_reverb_active = 1;
+float fsynth_reverb_damp = 0.4;
+float fsynth_reverb_level = 0.15;
+float fsynth_reverb_roomsize = 0.6;
+float fsynth_reverb_width = 4.0;
static fluid_synth_t *synth = NULL;
static fluid_settings_t *settings = NULL;
@@ -70,7 +79,7 @@ static boolean I_FL_InitMusic(void)
{
int sf_id;
- if (strlen(fluidsynth_sf_path) == 0)
+ if (strlen(fsynth_sf_path) == 0)
{
return false;
}
@@ -83,26 +92,37 @@ static boolean I_FL_InitMusic(void)
fluid_settings_setnum(settings, "synth.sample-rate", snd_samplerate);
- fluid_settings_setint(settings, "synth.chorus.active", mus_chorus);
- fluid_settings_setint(settings, "synth.reverb.active", mus_reverb);
+ fluid_settings_setint(settings, "synth.chorus.active",
+ fsynth_chorus_active);
+ fluid_settings_setint(settings, "synth.reverb.active",
+ fsynth_reverb_active);
- if (mus_reverb)
+ if (fsynth_reverb_active)
{
- fluid_settings_setnum(settings, "synth.reverb.room-size", 0.6);
- fluid_settings_setnum(settings, "synth.reverb.damp", 0.4);
- fluid_settings_setnum(settings, "synth.reverb.width", 4);
- fluid_settings_setnum(settings, "synth.reverb.level", 0.15);
+ fluid_settings_setnum(settings, "synth.reverb.room-size",
+ fsynth_reverb_roomsize);
+ fluid_settings_setnum(settings, "synth.reverb.damp",
+ fsynth_reverb_damp);
+ fluid_settings_setnum(settings, "synth.reverb.width",
+ fsynth_reverb_width);
+ fluid_settings_setnum(settings, "synth.reverb.level",
+ fsynth_reverb_level);
}
- if (mus_chorus)
+ if (fsynth_chorus_active)
{
- fluid_settings_setnum(settings, "synth.chorus.level", 0.35);
- fluid_settings_setnum(settings, "synth.chorus.depth", 5);
+ fluid_settings_setnum(settings, "synth.chorus.level",
+ fsynth_chorus_level);
+ fluid_settings_setnum(settings, "synth.chorus.depth",
+ fsynth_chorus_depth);
+ fluid_settings_setint(settings, "synth.chorus.nr", fsynth_chorus_nr);
+ fluid_settings_setnum(settings, "synth.chorus.speed",
+ fsynth_chorus_speed);
}
synth = new_fluid_synth(settings);
- sf_id = fluid_synth_sfload(synth, fluidsynth_sf_path, true);
+ sf_id = fluid_synth_sfload(synth, fsynth_sf_path, true);
if (sf_id == FLUID_FAILED)
{
// deleting the synth also deletes sfloader
@@ -110,11 +130,11 @@ static boolean I_FL_InitMusic(void)
delete_fluid_settings(settings);
fprintf(stderr,
"I_FL_InitMusic: Error loading FluidSynth soundfont: '%s'\n",
- fluidsynth_sf_path);
+ fsynth_sf_path);
return false;
}
- printf("I_FL_InitMusic: Using '%s'\n", fluidsynth_sf_path);
+ printf("I_FL_InitMusic: Using '%s'\n", fsynth_sf_path);
return true;
}
diff --git a/src/i_sdlmusic.c b/src/i_sdlmusic.c
index c9cafadb..fbfc0cd3 100644
--- a/src/i_sdlmusic.c
+++ b/src/i_sdlmusic.c
@@ -43,7 +43,6 @@
#include "z_zone.h"
-char *fluidsynth_sf_path = "";
char *timidity_cfg_path = "";
static char *temp_timidity_cfg = NULL;
diff --git a/src/i_sound.c b/src/i_sound.c
index 6232772b..0ed329e7 100644
--- a/src/i_sound.c
+++ b/src/i_sound.c
@@ -172,9 +172,8 @@ static void InitMusicModule(void)
// Skip the native Windows MIDI module if using Timidity or
// FluidSynth.
- if ((strcmp(timidity_cfg_path, "")
- || strcmp(fluidsynth_sf_path, ""))
- && music_modules[i] == &music_win_module)
+ if (strcmp(timidity_cfg_path, "") &&
+ music_modules[i] == &music_win_module)
{
continue;
}
@@ -504,7 +503,6 @@ 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);
@@ -516,6 +514,20 @@ void I_BindSoundVariables(void)
M_BindIntVariable("winmm_chorus_level", &winmm_chorus_level);
#endif
+#if HAVE_FLUIDSYNTH
+ M_BindIntVariable("fsynth_chorus_active", &fsynth_chorus_active);
+ M_BindFloatVariable("fsynth_chorus_depth", &fsynth_chorus_depth);
+ M_BindFloatVariable("fsynth_chorus_level", &fsynth_chorus_level);
+ M_BindIntVariable("fsynth_chorus_nr", &fsynth_chorus_nr);
+ M_BindFloatVariable("fsynth_chorus_speed", &fsynth_chorus_speed);
+ M_BindIntVariable("fsynth_reverb_active", &fsynth_reverb_active);
+ M_BindFloatVariable("fsynth_reverb_damp", &fsynth_reverb_damp);
+ M_BindFloatVariable("fsynth_reverb_level", &fsynth_reverb_level);
+ M_BindFloatVariable("fsynth_reverb_roomsize", &fsynth_reverb_roomsize);
+ M_BindFloatVariable("fsynth_reverb_width", &fsynth_reverb_width);
+ M_BindStringVariable("fsynth_sf_path", &fsynth_sf_path);
+#endif // HAVE_FLUIDSYNTH
+
M_BindIntVariable("use_libsamplerate", &use_libsamplerate);
M_BindFloatVariable("libsamplerate_scale", &libsamplerate_scale);
}
diff --git a/src/i_sound.h b/src/i_sound.h
index d4bc9404..758da15d 100644
--- a/src/i_sound.h
+++ b/src/i_sound.h
@@ -268,7 +268,6 @@ extern int opl_io_port;
// For native music module:
extern char *music_pack_path;
-extern char *fluidsynth_sf_path;
extern char *timidity_cfg_path;
#ifdef _WIN32
extern char *winmm_midi_device;
@@ -278,5 +277,20 @@ extern int winmm_reverb_level;
extern int winmm_chorus_level;
#endif
-#endif
+// For FluidSynth module:
+
+#if HAVE_FLUIDSYNTH
+extern char *fsynth_sf_path;
+extern int fsynth_chorus_active;
+extern float fsynth_chorus_depth;
+extern float fsynth_chorus_level;
+extern int fsynth_chorus_nr;
+extern float fsynth_chorus_speed;
+extern int fsynth_reverb_active;
+extern float fsynth_reverb_damp;
+extern float fsynth_reverb_level;
+extern float fsynth_reverb_roomsize;
+extern float fsynth_reverb_width;
+#endif // HAVE_FLUIDSYNTH
+#endif
diff --git a/src/m_config.c b/src/m_config.c
index d145f904..06d0200e 100644
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -936,11 +936,83 @@ static default_t extra_defaults_list[] =
CONFIG_VARIABLE_STRING(music_pack_path),
+#if HAVE_FLUIDSYNTH
+ //!
+ // If 1, activate the FluidSynth chorus effects module. If 0, no chorus
+ // will be added to the output signal.
+ //
+
+ CONFIG_VARIABLE_INT(fsynth_chorus_active),
+
+ //!
+ // Specifies the modulation depth of the FluidSynth chorus. Default is
+ // 5.0, range is 0.0 to 256.0.
+ //
+
+ CONFIG_VARIABLE_FLOAT(fsynth_chorus_depth),
+
+ //!
+ // Specifies the output amplitude of the FluidSynth chorus signal. Default
+ // is 0.35, range is 0.0 to 10.0.
+ //
+
+ CONFIG_VARIABLE_FLOAT(fsynth_chorus_level),
+
+ //!
+ // Sets the voice count of the FluidSynth chorus signal. Default is 3,
+ // range is 0 to 99.
+ //
+
+ CONFIG_VARIABLE_INT(fsynth_chorus_nr),
+
+ //!
+ // Sets the FluidSynth chorus modulation speed in Hz. Default is 0.3,
+ // range is 0.1 to 5.0.
+ //
+
+ CONFIG_VARIABLE_FLOAT(fsynth_chorus_speed),
+
+ //!
+ // If 1, activate the FluidSynth reverb effects module. If 0, no reverb
+ // will be added to the output signal.
+ //
+
+ CONFIG_VARIABLE_INT(fsynth_reverb_active),
+
+ //!
+ // Sets the amount of FluidSynth reverb damping. Default is 0.4, range is
+ // 0.0 to 1.0.
+ //
+
+ CONFIG_VARIABLE_FLOAT(fsynth_reverb_damp),
+
+ //!
+ // Sets the FluidSynth reverb amplitude. Default is 0.15, range is 0.0 -
+ // 1.0.
+ //
+
+ CONFIG_VARIABLE_FLOAT(fsynth_reverb_level),
+
+ //!
+ // Sets the room size(i.e. amount of wet) FluidSynth reverb. Default is
+ // 0.6, range is 0.0 - 1.0.
+ //
+
+ CONFIG_VARIABLE_FLOAT(fsynth_reverb_roomsize),
+
+ //!
+ // Sets the stereo spread of the FluidSynth reverb signal. Default is
+ // 0.4, range is 0.0 - 100.0.
+ //
+
+ CONFIG_VARIABLE_FLOAT(fsynth_reverb_width),
+
//!
// Full path to a soundfont file to use with FluidSynth MIDI playback.
//
- CONFIG_VARIABLE_STRING(fluidsynth_sf_path),
+ CONFIG_VARIABLE_STRING(fsynth_sf_path),
+#endif // HAVE_FLUIDSYNTH
//!
// Full path to a Timidity configuration file to use for MIDI
diff --git a/src/setup/sound.c b/src/setup/sound.c
index 2cc5aa71..edbdbf61 100644
--- a/src/setup/sound.c
+++ b/src/setup/sound.c
@@ -73,7 +73,6 @@ float libsamplerate_scale = 0.65;
char *music_pack_path = NULL;
char *timidity_cfg_path = NULL;
-char *fluidsynth_sf_path = NULL;
static char *gus_patch_path = NULL;
static int gus_ram_kb = 1024;
#ifdef _WIN32
@@ -88,6 +87,20 @@ int winmm_reverb_level = -1;
int winmm_chorus_level = -1;
#endif
+#if HAVE_FLUIDSYNTH
+char *fsynth_sf_path = NULL;
+int fsynth_chorus_active = 1;
+float fsynth_chorus_depth = 5.0;
+float fsynth_chorus_level = 0.35;
+int fsynth_chorus_nr = 3;
+float fsynth_chorus_speed = 0.3;
+int fsynth_reverb_active = 1;
+float fsynth_reverb_damp = 0.4;
+float fsynth_reverb_level = 0.15;
+float fsynth_reverb_roomsize = 0.6;
+float fsynth_reverb_width = 4.0;
+#endif // HAVE_FLUIDSYNTH
+
// DOS specific variables: these are unused but should be maintained
// so that the config file can be shared between chocolate
// doom and doom.exe
@@ -315,7 +328,7 @@ void ConfigSound(TXT_UNCAST_ARG(widget), void *user_data)
TXT_NewStrut(4, 0),
TXT_NewLabel("FluidSynth soundfont file: "),
TXT_NewStrut(4, 0),
- TXT_NewFileSelector(&fluidsynth_sf_path, 34,
+ TXT_NewFileSelector(&fsynth_sf_path, 34,
"Select FluidSynth soundfont file",
sf_extension),
NULL)),
@@ -338,7 +351,6 @@ void BindSoundVariables(void)
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);
#ifdef _WIN32
M_BindStringVariable("winmm_midi_device", &winmm_midi_device);
M_BindIntVariable("winmm_reset_type", &winmm_reset_type);
@@ -347,6 +359,20 @@ void BindSoundVariables(void)
M_BindIntVariable("winmm_chorus_level", &winmm_chorus_level);
#endif
+#if HAVE_FLUIDSYNTH
+ M_BindIntVariable("fsynth_chorus_active", &fsynth_chorus_active);
+ M_BindFloatVariable("fsynth_chorus_depth", &fsynth_chorus_depth);
+ M_BindFloatVariable("fsynth_chorus_level", &fsynth_chorus_level);
+ M_BindIntVariable("fsynth_chorus_nr", &fsynth_chorus_nr);
+ M_BindFloatVariable("fsynth_chorus_speed", &fsynth_chorus_speed);
+ M_BindIntVariable("fsynth_reverb_active", &fsynth_reverb_active);
+ M_BindFloatVariable("fsynth_reverb_damp", &fsynth_reverb_damp);
+ M_BindFloatVariable("fsynth_reverb_level", &fsynth_reverb_level);
+ M_BindFloatVariable("fsynth_reverb_roomsize", &fsynth_reverb_roomsize);
+ M_BindFloatVariable("fsynth_reverb_width", &fsynth_reverb_width);
+ M_BindStringVariable("fsynth_sf_path", &fsynth_sf_path);
+#endif // HAVE_FLUIDSYNTH
+
M_BindIntVariable("snd_sbport", &snd_sbport);
M_BindIntVariable("snd_sbirq", &snd_sbirq);
M_BindIntVariable("snd_sbdma", &snd_sbdma);
@@ -369,7 +395,7 @@ void BindSoundVariables(void)
music_pack_path = M_StringDuplicate("");
timidity_cfg_path = M_StringDuplicate("");
gus_patch_path = M_StringDuplicate("");
- fluidsynth_sf_path = M_StringDuplicate("");
+ fsynth_sf_path = M_StringDuplicate("");
// All versions of Heretic and Hexen did pitch-shifting.
// Most versions of Doom did not and Strife never did.