From 39f26028aaa02aa7bd180466ed09f8f29acc87fd Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 23 Feb 2018 19:23:39 +0100 Subject: [PATCH] - reworked the advanced sound menu to take advantage of the new soundfont handling. The text input field for the configs have been removed. Instead it will now present a list of soundfonts that are found in specific locations. For that it will look in the 'soundfont' directories of the FileSearch.Directories entry of the config. Acceptable file formats here are SF2 and zipped GUS patch sets. These zipped patch sets need to have a timidity.cfg at the root and refer to all containing data by relative path. References to outside files are not allowed here. It is still possible to refer to sound fonts elsewhere on the hard drive by manually entering a path at the console - but these won't show in the menu and will get lost if one cycles through the list of available options. Of the available softsynths, FluidSynth will only list SF", Wildmidi will only list GUS patch sets and Timidity++ and GUS will list both. Please note that although the GUS synth can read SF2, the output appears to be broken die to some old bug. --- src/menu/menudef.cpp | 22 ++++++++++++++ src/namedef.h | 6 ++++ src/sound/i_soundfont.cpp | 22 ++++++++++++++ src/sound/i_soundfont.h | 2 ++ wadsrc/static/menudef.txt | 61 +++++++++++++++------------------------ 5 files changed, 76 insertions(+), 37 deletions(-) diff --git a/src/menu/menudef.cpp b/src/menu/menudef.cpp index 39be1eea93..f8e395f1d5 100644 --- a/src/menu/menudef.cpp +++ b/src/menu/menudef.cpp @@ -55,6 +55,7 @@ #include "types.h" #include "gameconfigfile.h" #include "m_argv.h" +#include "i_soundfont.h" @@ -1537,6 +1538,27 @@ void M_CreateMenus() { I_BuildALResamplersList(*opt); } + opt = OptionValues.CheckKey(NAME_GUSConfig); + if (opt != nullptr) + { + I_BuildSoundFontList(*opt, SF_GUS|SF_SF2); + } + opt = OptionValues.CheckKey(NAME_TimidityConfig); + if (opt != nullptr) + { + I_BuildSoundFontList(*opt, SF_GUS | SF_SF2); + } + opt = OptionValues.CheckKey(NAME_WildmidiConfig); + if (opt != nullptr) + { + I_BuildSoundFontList(*opt, SF_GUS); + } + opt = OptionValues.CheckKey(NAME_FluidConfig); + if (opt != nullptr) + { + I_BuildSoundFontList(*opt, SF_SF2); + } + } //============================================================================= diff --git a/src/namedef.h b/src/namedef.h index ace456a691..cefe54fe07 100644 --- a/src/namedef.h +++ b/src/namedef.h @@ -946,3 +946,9 @@ xx(snd_output) xx(snd_output_format) xx(snd_speakermode) xx(snd_resampler) + +// soundfont options +xx(GUSConfig) +xx(FluidConfig) +xx(TimidityConfig) +xx(WildmidiConfig) diff --git a/src/sound/i_soundfont.cpp b/src/sound/i_soundfont.cpp index 634b6448bd..8434ced58a 100644 --- a/src/sound/i_soundfont.cpp +++ b/src/sound/i_soundfont.cpp @@ -41,6 +41,7 @@ #include "i_system.h" #include "gameconfigfile.h" #include "resourcefiles/resourcefile.h" +#include "menu/menu.h" FSoundFontManager sfmanager; @@ -468,4 +469,25 @@ void I_InitSoundFonts() sfmanager.CollectSoundfonts(); } +//========================================================================== +// +// +// +//========================================================================== +void I_BuildSoundFontList(FOptionValues *opt, int allowed) +{ + auto &list = sfmanager.GetList(); + for (auto &entry : list) + { + if (entry.type & allowed) + { + FString display = entry.mName; + display.ReplaceChars("_", ' '); + FOptionValues::Pair pair; + pair.Text = display; + pair.TextValue = entry.mName; + opt->mValues.Push(pair); + } + } +} diff --git a/src/sound/i_soundfont.h b/src/sound/i_soundfont.h index 9208351e48..22a60683fb 100644 --- a/src/sound/i_soundfont.h +++ b/src/sound/i_soundfont.h @@ -150,3 +150,5 @@ public: extern FSoundFontManager sfmanager; +struct FOptionValues; +void I_BuildSoundFontList(FOptionValues *opt, int allowed); diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 663c20ec9a..97235d7b23 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -1657,6 +1657,26 @@ OptionValue OplCores 3, "$OPTVAL_NUKEDOPL3" } +OptionValue GUSConfig +{ + // filled in by the sound code +} + +OptionValue WildMidiConfig +{ + // filled in by the sound code +} + +OptionValue TimidityConfig +{ + // filled in by the sound code +} + +OptionValue FluidConfig +{ + // filled in by the sound code +} + OptionMenu AdvSoundOptions protected { Title "$ADVSNDMNU_TITLE" @@ -1669,15 +1689,13 @@ OptionMenu AdvSoundOptions protected Option "$ADVSNDMNU_OPLCORES", "opl_core", "OplCores" StaticText " " StaticText "$ADVSNDMNU_GUSEMULATION", 1 - TextField "$ADVSNDMNU_GUSCONFIG", "midi_config" - SubMenu "$ADVSNDMNU_SELCONFIG", "GusConfigMenu" + Option "$ADVSNDMNU_GUSCONFIG", "midi_config", GUSConfig Slider "$ADVSNDMNU_MIDIVOICES", "midi_voices", 16, 256, 4, 0 Option "$ADVSNDMNU_DMXGUS", "midi_dmxgus", "OnOff" Option "$ADVSNDMNU_GUSMEMSIZE", "gus_memsize", "GusMemory" StaticText " " StaticText "$ADVSNDMNU_FLUIDSYNTH", 1 - TextField "$ADVSNDMNU_FLUIDPATCHSET", "fluid_patchset" - SubMenu "$ADVSNDMNU_SELCONFIG", "FluidPatchsetMenu" + Option "$ADVSNDMNU_FLUIDPATCHSET", "fluid_patchset", FluidConfig Slider "$ADVSNDMNU_FLUIDGAIN", "fluid_gain", 0, 10, 0.5, 1 Option "$ADVSNDMNU_REVERB", "fluid_reverb", "OnOff" Option "$ADVSNDMNU_CHORUS", "fluid_chorus", "OnOff" @@ -1685,46 +1703,15 @@ OptionMenu AdvSoundOptions protected // Leaving out the more advanced stuff for now. StaticText " " StaticText "$ADVSNDMNU_TIMIDITY", 1 - TextField "$ADVSNDMNU_TIMIDITYEXE", "timidity_exe" - IfOption(Windows) - { - SubMenu "$ADVSNDMNU_SELCONFIG", "TimidityExeMenu" - } - TextField "$ADVSNDMNU_TIMIDITYCONFIG", "timidity_config" - SubMenu "$ADVSNDMNU_SELCONFIG", "TimidityConfigMenu" + Option "$ADVSNDMNU_TIMIDITYCONFIG", "timidity_config", TimidityConfig Option "$ADVSNDMNU_REVERB", "timidity_reverb", "OnOff" Option "$ADVSNDMNU_CHORUS", "timidity_chorus", "OnOff" StaticText " " StaticText "$ADVSNDMNU_WILDMIDI", 1 - TextField "$ADVSNDMNU_WILDMIDICONFIG", "wildmidi_config" - SubMenu "$ADVSNDMNU_SELCONFIG", "WildMidiConfigMenu" + Option "$ADVSNDMNU_WILDMIDICONFIG", "wildmidi_config", WildmidiConfig Option "$ADVSNDMNU_REVERB", "wildmidi_reverb", "OnOff" } -OptionMenu GusConfigMenu protected -{ - Title "$ADVSNDMNU_SELCONFIG" -} - -OptionMenu WildMidiConfigMenu protected -{ - Title "$ADVSNDMNU_SELCONFIG" -} - -OptionMenu TimidityExeMenu protected -{ - Title "$ADVSNDMNU_SELCONFIG" -} - -OptionMenu TimidityConfigMenu protected -{ - Title "$ADVSNDMNU_SELCONFIG" -} - -OptionMenu FluidPatchsetMenu protected -{ - Title "$ADVSNDMNU_SELCONFIG" -} /*======================================= *