From 798ceddea6a1925ba578d958f305faf7c41b32c3 Mon Sep 17 00:00:00 2001 From: Wohlstand Date: Sat, 5 Jul 2025 15:19:33 +0300 Subject: [PATCH] Added gain for libADLMIDI and for libOPNMIDI --- src/common/audio/music/music.cpp | 2 ++ src/common/audio/music/music_config.cpp | 28 +++++++++++++++++++++++++ wadsrc/static/menudef.txt | 5 ++++- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/common/audio/music/music.cpp b/src/common/audio/music/music.cpp index 9664c5458..6d837d0f7 100644 --- a/src/common/audio/music/music.cpp +++ b/src/common/audio/music/music.cpp @@ -90,6 +90,8 @@ EXTERN_CVAR(Float, snd_musicvolume) EXTERN_CVAR(Int, snd_mididevice) EXTERN_CVAR(Float, mod_dumb_mastervolume) EXTERN_CVAR(Float, fluid_gain) +EXTERN_CVAR(Float, adl_gain) +EXTERN_CVAR(Float, opn_gain) CVAR(Bool, mus_calcgain, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) // changing this will only take effect for the next song. diff --git a/src/common/audio/music/music_config.cpp b/src/common/audio/music/music_config.cpp index 7a4b8a200..b0e2211d9 100644 --- a/src/common/audio/music/music_config.cpp +++ b/src/common/audio/music/music_config.cpp @@ -114,6 +114,20 @@ CUSTOM_CVAR(Bool, adl_auto_arpeggio, false, CVAR_ARCHIVE | CVAR_VIRTUAL) { FORWARD_BOOL_CVAR(adl_auto_arpeggio); } + +CUSTOM_CVAR(Float, adl_gain, 0.5, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_VIRTUAL) +{ + if (!mus_usereplaygain) + { + FORWARD_CVAR(adl_gain); + } + else + { + // Replay gain will disable the user setting for consistency. + float newval; + ChangeMusicSetting(zmusic_adl_gain, mus_playing.handle, 1.0f, & newval); + } +} #endif //========================================================================== // @@ -295,6 +309,20 @@ CUSTOM_CVAR(Bool, opn_auto_arpeggio, false, CVAR_ARCHIVE | CVAR_VIRTUAL) { FORWARD_BOOL_CVAR(adl_auto_arpeggio); } + +CUSTOM_CVAR(Float, opn_gain, 0.5, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_VIRTUAL) +{ + if (!mus_usereplaygain) + { + FORWARD_CVAR(opn_gain); + } + else + { + // Replay gain will disable the user setting for consistency. + float newval; + ChangeMusicSetting(zmusic_opn_gain, mus_playing.handle, 1.0f, & newval); + } +} //========================================================================== // // GUS MIDI device diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 3b568e392..0eb208f0c 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -2286,12 +2286,14 @@ OptionMenu ModReplayerOptions protected 4, "$OPTVAL_NP2OPNA" 5, "$OPTVAL_MAMEOPNA" 6, "$OPTVAL_YMFMOPNA" - 7, "$OPTVAL_NUKEDOPN2YM2612" + // 7'th is a VGM Dumper, it should NEVER been used during normal runtime + 8, "$OPTVAL_NUKEDOPN2YM2612" } OptionMenu ADLOptions protected { Title "$ADVSNDMNU_ADLMIDI" + Slider "$ADVSNDMNU_FLUIDGAIN", "adl_gain", 0, 10, 0.1, 1 Option "$ADVSNDMNU_OPLCORES", "adl_emulator_id", "ADLOplCores" Option "$ADVSNDMNU_RUNPCMRATE", "adl_run_at_pcm_rate", "OnOff" Slider "$ADVSNDMNU_ADLNUMCHIPS", "adl_chips_count", 1, 32, 1, 0 @@ -2309,6 +2311,7 @@ OptionMenu ModReplayerOptions protected OptionMenu OPNOptions protected { Title "$ADVSNDMNU_OPNMIDI" + Slider "$ADVSNDMNU_FLUIDGAIN", "opn_gain", 0, 10, 0.1, 1 Option "$ADVSNDMNU_OPNCORES", "opn_emulator_id", "OpnCores" Option "$ADVSNDMNU_RUNPCMRATE", "opn_run_at_pcm_rate", "OnOff" Slider "$ADVSNDMNU_OPNNUMCHIPS", "opn_chips_count", 1, 32, 1, 0