diff --git a/src/menu/menudef.cpp b/src/menu/menudef.cpp index f8e395f1d..036be616c 100644 --- a/src/menu/menudef.cpp +++ b/src/menu/menudef.cpp @@ -1384,91 +1384,40 @@ static void InitCrosshairsList() static void InitMusicMenus() { DMenuDescriptor **advmenu = MenuDescriptors.CheckKey("AdvSoundOptions"); - DMenuDescriptor **gusmenu = MenuDescriptors.CheckKey("GusConfigMenu"); - DMenuDescriptor **timiditymenu = MenuDescriptors.CheckKey("TimidityExeMenu"); - DMenuDescriptor **wildmidimenu = MenuDescriptors.CheckKey("WildMidiConfigMenu"); - DMenuDescriptor **timiditycfgmenu = MenuDescriptors.CheckKey("TimidityConfigMenu"); - DMenuDescriptor **fluidmenu = MenuDescriptors.CheckKey("FluidPatchsetMenu"); + auto soundfonts = sfmanager.GetList(); + std::tuple sfmenus[] = { std::make_tuple("GusConfigMenu", SF_SF2 | SF_GUS, "midi_config"), + std::make_tuple("WildMidiConfigMenu", SF_GUS, "wildmidi_config"), + std::make_tuple("TimidityConfigMenu", SF_SF2 | SF_GUS, "timidity_config"), + std::make_tuple("FluidPatchsetMenu", SF_SF2, "fluid_patchset") }; - const char *key, *value; - if (GameConfig->SetSection("SoundFonts")) + for (auto &p : sfmenus) { - while (GameConfig->NextInSection(key, value)) + DMenuDescriptor **menu = MenuDescriptors.CheckKey(std::get<0>(p)); + + if (menu != nullptr) { - if (FileExists(value)) + if (soundfonts.Size() > 0) { - if (fluidmenu != nullptr) + for (auto &entry : soundfonts) { - auto it = CreateOptionMenuItemCommand(key, FStringf("fluid_patchset %s", NicePath(value).GetChars()), true); - static_cast(*fluidmenu)->mItems.Push(it); + if (entry.type & std::get<1>(p)) + { + FString display = entry.mName; + display.ReplaceChars("_", ' '); + auto it = CreateOptionMenuItemCommand(display, FStringf("%s %s", std::get<2>(p), entry.mName), true); + static_cast(*menu)->mItems.Push(it); + } } } + else if (advmenu != nullptr) + { + // Remove the item for this submenu + auto d = static_cast(*advmenu); + auto it = d->GetItem(std::get<0>(p)); + if (it != nullptr) d->mItems.Delete(d->mItems.Find(it)); + } } } - else if (advmenu != nullptr) - { - // Remove the item for this submenu - auto d = static_cast(*advmenu); - auto it = d->GetItem("FluidPatchsetMenu"); - if (it != nullptr) d->mItems.Delete(d->mItems.Find(it)); - } - if (GameConfig->SetSection("PatchSets")) - { - while (GameConfig->NextInSection(key, value)) - { - if (FileExists(value)) - { - if (gusmenu != nullptr) - { - auto it = CreateOptionMenuItemCommand(key, FStringf("midi_config %s", NicePath(value).GetChars()), true); - static_cast(*gusmenu)->mItems.Push(it); - } - if (wildmidimenu != nullptr) - { - auto it = CreateOptionMenuItemCommand(key, FStringf("wildmidi_config %s", NicePath(value).GetChars()), true); - static_cast(*wildmidimenu)->mItems.Push(it); - } - if (timiditycfgmenu != nullptr) - { - auto it = CreateOptionMenuItemCommand(key, FStringf("timidity_config \"%s\"", NicePath(value).GetChars()), true); - static_cast(*timiditycfgmenu)->mItems.Push(it); - } - } - } - } - else if (advmenu != nullptr) - { - // Remove the item for this submenu - auto d = static_cast(*advmenu); - auto it = d->GetItem("GusConfigMenu"); - if (it != nullptr) d->mItems.Delete(d->mItems.Find(it)); - it = d->GetItem("WildMidiConfigMenu"); - if (it != nullptr) d->mItems.Delete(d->mItems.Find(it)); - it = d->GetItem("TimidityConfigMenu"); - if (it != nullptr) d->mItems.Delete(d->mItems.Find(it)); - } -#ifdef _WIN32 // Different Timidity paths only make sense if they can be stored in arbitrary paths with local configs (i.e. not if things are done the Linux way) - if (GameConfig->SetSection("TimidityExes")) - { - while (GameConfig->NextInSection(key, value)) - { - if (FileExists(value)) - { - if (timiditymenu != nullptr) - { - auto it = CreateOptionMenuItemCommand(key, FStringf("timidity_exe %s", NicePath(value).GetChars()), true); - static_cast(*timiditymenu)->mItems.Push(it); - } - } - } - } - else - { - auto d = static_cast(*advmenu); - auto it = d->GetItem("TimidityExeMenu"); - if (it != nullptr) d->mItems.Delete(d->mItems.Find(it)); - } -#endif } //============================================================================= @@ -1538,27 +1487,6 @@ 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 cefe54fe0..ace456a69 100644 --- a/src/namedef.h +++ b/src/namedef.h @@ -946,9 +946,3 @@ 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 c4d88cfa7..77e85be08 100644 --- a/src/sound/i_soundfont.cpp +++ b/src/sound/i_soundfont.cpp @@ -41,7 +41,6 @@ #include "i_system.h" #include "gameconfigfile.h" #include "resourcefiles/resourcefile.h" -#include "menu/menu.h" FSoundFontManager sfmanager; @@ -469,25 +468,4 @@ 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 22a60683f..9208351e4 100644 --- a/src/sound/i_soundfont.h +++ b/src/sound/i_soundfont.h @@ -150,5 +150,3 @@ public: extern FSoundFontManager sfmanager; -struct FOptionValues; -void I_BuildSoundFontList(FOptionValues *opt, int allowed); diff --git a/src/sound/timiditypp/playmidi.cpp b/src/sound/timiditypp/playmidi.cpp index 59e4c94d3..0848a80c4 100644 --- a/src/sound/timiditypp/playmidi.cpp +++ b/src/sound/timiditypp/playmidi.cpp @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -5027,11 +5028,13 @@ int Player::compute_data(float *buffer, int32_t count) timidity_drum_power = ::timidity_drum_power; timidity_key_adjust = ::timidity_key_adjust; timidity_tempo_adjust = ::timidity_tempo_adjust; + std::atomic_thread_fence(std::memory_order_acq_rel); effect->timidity_chorus = timidity_chorus; if (::timidity_reverb != timidity_reverb) { timidity_reverb = ::timidity_reverb; + std::atomic_thread_fence(std::memory_order_acq_rel); reverb->timidity_reverb = timidity_reverb; // If the reverb mode has changed some buffers need to be reallocated before doing any sound generation. diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index 501436552..eabe3b2f5 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2451,7 +2451,7 @@ OPTSTR_SPLINE = "Spline"; OPTSTR_OPENAL = "OpenAL"; - +NOTSET = "Not set"; SAFEMESSAGE = "Do you really want to do this?"; MNU_COLORPICKER = "SELECT COLOR"; diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 97235d7b2..09604328c 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -1657,25 +1657,6 @@ 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 { @@ -1689,13 +1670,13 @@ OptionMenu AdvSoundOptions protected Option "$ADVSNDMNU_OPLCORES", "opl_core", "OplCores" StaticText " " StaticText "$ADVSNDMNU_GUSEMULATION", 1 - Option "$ADVSNDMNU_GUSCONFIG", "midi_config", GUSConfig + LabeledSubMenu "$ADVSNDMNU_SELCONFIG", "midi_config", "GusConfigMenu" 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 - Option "$ADVSNDMNU_FLUIDPATCHSET", "fluid_patchset", FluidConfig + LabeledSubMenu "$ADVSNDMNU_SELCONFIG", "fluid_patchset", "FluidPatchsetMenu" Slider "$ADVSNDMNU_FLUIDGAIN", "fluid_gain", 0, 10, 0.5, 1 Option "$ADVSNDMNU_REVERB", "fluid_reverb", "OnOff" Option "$ADVSNDMNU_CHORUS", "fluid_chorus", "OnOff" @@ -1703,15 +1684,36 @@ OptionMenu AdvSoundOptions protected // Leaving out the more advanced stuff for now. StaticText " " StaticText "$ADVSNDMNU_TIMIDITY", 1 - Option "$ADVSNDMNU_TIMIDITYCONFIG", "timidity_config", TimidityConfig - Option "$ADVSNDMNU_REVERB", "timidity_reverb", "OnOff" + + LabeledSubMenu "$ADVSNDMNU_SELCONFIG", "timidity_config", "TimidityConfigMenu" + // This one needs reworking + //Option "$ADVSNDMNU_REVERB", "timidity_reverb", "OnOff" Option "$ADVSNDMNU_CHORUS", "timidity_chorus", "OnOff" StaticText " " StaticText "$ADVSNDMNU_WILDMIDI", 1 - Option "$ADVSNDMNU_WILDMIDICONFIG", "wildmidi_config", WildmidiConfig + LabeledSubMenu "$ADVSNDMNU_SELCONFIG", "wildmidi_config", "WildMidiConfigMenu" Option "$ADVSNDMNU_REVERB", "wildmidi_reverb", "OnOff" } +OptionMenu GusConfigMenu protected +{ + Title "$ADVSNDMNU_SELCONFIG" +} + +OptionMenu WildMidiConfigMenu protected +{ + Title "$ADVSNDMNU_SELCONFIG" +} + +OptionMenu TimidityConfigMenu protected +{ + Title "$ADVSNDMNU_SELCONFIG" +} + +OptionMenu FluidPatchsetMenu protected +{ + Title "$ADVSNDMNU_SELCONFIG" +} /*======================================= * diff --git a/wadsrc/static/zscript/menu/optionmenuitems.txt b/wadsrc/static/zscript/menu/optionmenuitems.txt index 00fe4893c..b93468c0c 100644 --- a/wadsrc/static/zscript/menu/optionmenuitems.txt +++ b/wadsrc/static/zscript/menu/optionmenuitems.txt @@ -118,6 +118,34 @@ class OptionMenuItemSubmenu : OptionMenuItem } } +//============================================================================= +// +// opens a submenu, command is a submenu name +// +//============================================================================= + +class OptionMenuItemLabeledSubmenu : OptionMenuItemSubmenu +{ + CVar mLabelCVar; + OptionMenuItemSubmenu Init(String label, CVar labelcvar, Name command, int param = 0) + { + Super.init(label, command, false); + mLabelCVar = labelcvar; + return self; + } + + override int Draw(OptionMenuDescriptor desc, int y, int indent, bool selected) + { + drawLabel(indent, y, selected? OptionMenuSettings.mFontColorSelection : OptionMenuSettings.mFontColor); + + String text = mLabelCVar.GetString(); + if (text.Length() == 0) text = Stringtable.Localize("$notset"); + screen.DrawText (SmallFont, OptionMenuSettings.mFontColorValue, indent + CursorSpace(), y, text, DTA_CleanNoMove_1, true); + + return indent; + } +} + //============================================================================= // // Executes a CCMD, command is a CCMD name