Use improved FluidSynth reverb/chorus defaults, add config settings (#1993)

* Rename reverb/chorus settings

* Rename gain setting

* Use consistent descriptions

* Expose polyphony/reverb/chorus settings in config

Defaults based on recommendations from the author of GeneralUser GS. Very similar to the improved defaults for FluidSynth 2.4.0.

* Expose interpolation setting in config

The author of GeneralUser GS recommends the highest quality interpolation method, but the default method has lower CPU usage.
This commit is contained in:
ceski 2024-11-07 20:09:20 -08:00 committed by GitHub
parent e7c0f19fbe
commit 1a4184da65
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 77 additions and 29 deletions

View File

@ -47,14 +47,25 @@ typedef fluid_long_long_t fluid_int_t;
#include "z_zone.h"
static const char *soundfont_dir = "";
static boolean mus_chorus;
static boolean mus_reverb;
static int fl_polyphony;
static boolean fl_interpolation;
static boolean fl_reverb;
static boolean fl_chorus;
static int fl_reverb_damp;
static int fl_reverb_level;
static int fl_reverb_roomsize;
static int fl_reverb_width;
static int fl_chorus_depth;
static int fl_chorus_level;
static int fl_chorus_nr;
static int fl_chorus_speed;
static fluid_synth_t *synth = NULL;
static fluid_settings_t *settings = NULL;
static fluid_player_t *player = NULL;
static const char **soundfonts = NULL;
static int interp_method;
// Load SNDFONT lump
@ -243,23 +254,38 @@ static boolean I_FL_InitStream(int device)
settings = new_fluid_settings();
interp_method =
fl_interpolation ? FLUID_INTERP_HIGHEST : FLUID_INTERP_DEFAULT;
fluid_settings_setint(settings, "synth.polyphony", fl_polyphony);
fluid_settings_setnum(settings, "synth.gain", 0.2);
fluid_settings_setnum(settings, "synth.sample-rate", SND_SAMPLERATE);
fluid_settings_setint(settings, "synth.device-id", 16);
fluid_settings_setstr(settings, "synth.midi-bank-select", "gs");
fluid_settings_setint(settings, "synth.reverb.active", fl_reverb);
fluid_settings_setint(settings, "synth.chorus.active", fl_chorus);
fluid_settings_setint(settings, "synth.chorus.active", mus_chorus);
fluid_settings_setint(settings, "synth.reverb.active", mus_reverb);
if (mus_reverb)
if (fl_reverb)
{
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.damp",
fl_reverb_damp / 100.0);
fluid_settings_setnum(settings, "synth.reverb.level",
fl_reverb_level / 100.0);
fluid_settings_setnum(settings, "synth.reverb.room-size",
fl_reverb_roomsize / 100.0);
fluid_settings_setnum(settings, "synth.reverb.width",
fl_reverb_width / 100.0);
}
if (mus_chorus)
if (fl_chorus)
{
fluid_settings_setnum(settings, "synth.chorus.level", 0.35);
fluid_settings_setnum(settings, "synth.chorus.depth", 5);
fluid_settings_setnum(settings, "synth.chorus.depth",
fl_chorus_depth / 100.0);
fluid_settings_setnum(settings, "synth.chorus.level",
fl_chorus_level / 100.0);
fluid_settings_setint(settings, "synth.chorus.nr", fl_chorus_nr);
fluid_settings_setnum(settings, "synth.chorus.speed",
fl_chorus_speed / 100.0);
}
synth = new_fluid_synth(settings);
@ -407,6 +433,7 @@ static void I_FL_PlayStream(boolean looping)
return;
}
fluid_synth_set_interp_method(synth, -1, interp_method);
fluid_player_set_loop(player, looping ? -1 : 1);
fluid_player_play(player);
}
@ -480,9 +507,31 @@ static void I_FL_BindVariables(void)
// AppImage
"../share/" PROJECT_SHORTNAME "/soundfonts",
#endif
wad_no, "FluidSynth soundfont directories");
BIND_BOOL_MIDI(mus_chorus, false, "FluidSynth chorus");
BIND_BOOL_MIDI(mus_reverb, false, "FluidSynth reverb");
wad_no, "[FluidSynth] Soundfont directories");
BIND_NUM(fl_polyphony, 256, 1, 65535,
"[FluidSynth] Number of voices that can be played in parallel");
BIND_BOOL(fl_interpolation, false,
"[FluidSynth] Interpolation method (0 = Default; 1 = Highest Quality)");
BIND_BOOL_MIDI(fl_reverb, false,
"[FluidSynth] Enable reverb effects");
BIND_BOOL_MIDI(fl_chorus, false,
"[FluidSynth] Enable chorus effects");
BIND_NUM(fl_reverb_damp, 30, 0, 100,
"[FluidSynth] Reverb damping");
BIND_NUM(fl_reverb_level, 70, 0, 100,
"[FluidSynth] Reverb output level");
BIND_NUM(fl_reverb_roomsize, 50, 0, 100,
"[FluidSynth] Reverb room size");
BIND_NUM(fl_reverb_width, 80, 0, 10000,
"[FluidSynth] Reverb width (stereo spread)");
BIND_NUM(fl_chorus_depth, 360, 0, 25600,
"[FluidSynth] Chorus modulation depth");
BIND_NUM(fl_chorus_level, 55, 0, 1000,
"[FluidSynth] Chorus output level");
BIND_NUM(fl_chorus_nr, 4, 0, 99,
"[FluidSynth] Chorus voice count");
BIND_NUM(fl_chorus_speed, 36, 10, 500,
"[FluidSynth] Chorus modulation speed");
}
static const char *I_FL_MusicFormat(void)

View File

@ -1501,14 +1501,14 @@ static const char *I_MID_MusicFormat(void)
static void I_MID_BindVariables(void)
{
BIND_NUM_MIDI(midi_complevel, COMP_STANDARD, 0, COMP_NUM - 1,
"Native MIDI compatibility level (0 = Vanilla; 1 = Standard; 2 = Full)");
"[Native MIDI] Compatibility level (0 = Vanilla; 1 = Standard; 2 = Full)");
BIND_NUM_MIDI(midi_reset_type, RESET_TYPE_GM, 0, RESET_NUM - 1,
"Reset type for native MIDI (0 = No SysEx; 1 = GM; 2 = GS; 3 = XG)");
"[Native MIDI] Reset type (0 = No SysEx; 1 = GM; 2 = GS; 3 = XG)");
BIND_NUM(midi_reset_delay, -1, -1, 2000,
"Delay after reset for native MIDI (-1 = Auto; 0 = None; 1-2000 = Milliseconds)");
"[Native MIDI] Delay after reset (-1 = Auto; 0 = None; 1-2000 = Milliseconds)");
BIND_BOOL_MIDI(midi_ctf, true,
"Fix invalid instruments by emulating SC-55 capital tone fallback");
BIND_NUM_MIDI(midi_gain, 0, -20, 0, "Native MIDI gain [dB]");
"[Native MIDI] Fix invalid instruments by emulating SC-55 capital tone fallback");
BIND_NUM_MIDI(midi_gain, 0, -20, 0, "[Native MIDI] Gain [dB]");
}
music_module_t music_mid_module =

View File

@ -295,8 +295,7 @@ static boolean I_OAL_InitMusic(int device)
return false;
}
static int mus_gain = 100;
static int opl_gain = 200;
static int fl_gain, opl_gain;
static void I_OAL_SetMusicVolume(int volume)
{
@ -314,7 +313,7 @@ static void I_OAL_SetMusicVolume(int volume)
#if defined(HAVE_FLUIDSYNTH)
else if (active_module == &stream_fl_module)
{
gain *= (ALfloat)DB_TO_GAIN(mus_gain);
gain *= (ALfloat)DB_TO_GAIN(fl_gain);
}
#endif
@ -476,10 +475,10 @@ static midiplayertype_t I_OAL_MidiPlayerType(void)
static void I_OAL_BindVariables(void)
{
BIND_NUM_MIDI(opl_gain, 0, -20, 20, "OPL emulation gain [dB]");
#if defined (HAVE_FLUIDSYNTH)
BIND_NUM_MIDI(mus_gain, 0, -20, 20, "FluidSynth gain [dB]");
BIND_NUM_MIDI(fl_gain, 0, -20, 20, "[FluidSynth] Gain [dB]");
#endif
BIND_NUM_MIDI(opl_gain, 0, -20, 20, "[OPL3 Emulation] Gain [dB]");
for (int i = 0; i < arrlen(midi_modules); ++i)
{
midi_modules[i]->BindVariables();

View File

@ -2590,13 +2590,13 @@ static setup_menu_t midi_settings1[] = {
MI_GAP,
#if defined (HAVE_FLUIDSYNTH)
{"FluidSynth Gain", S_THERMO, CNTR_X, M_THRM_SPC, {"mus_gain"},
{"FluidSynth Gain", S_THERMO, CNTR_X, M_THRM_SPC, {"fl_gain"},
.action = UpdateMusicVolume, .append = "dB"},
{"FluidSynth Reverb", S_ONOFF, CNTR_X, M_SPC, {"mus_reverb"},
{"FluidSynth Reverb", S_ONOFF, CNTR_X, M_SPC, {"fl_reverb"},
.action = SetMidiPlayerFluidSynth},
{"FluidSynth Chorus", S_ONOFF, CNTR_X, M_SPC, {"mus_chorus"},
{"FluidSynth Chorus", S_ONOFF, CNTR_X, M_SPC, {"fl_chorus"},
.action = SetMidiPlayerFluidSynth},
MI_GAP,