- disable the player specific volume modifiers if replay gain is enabled.

These two functions would get into the way of each other otherwise.
This commit is contained in:
Christoph Oelckers 2021-03-14 09:05:28 +01:00
parent aa789c7605
commit 90cb82d244
2 changed files with 29 additions and 3 deletions

View file

@ -82,8 +82,11 @@ static MusicCallbacks mus_cb = { nullptr, DefaultOpenMusic };
// PUBLIC DATA DEFINITIONS -------------------------------------------------
EXTERN_CVAR(Int, snd_mididevice)
EXTERN_CVAR(Float, mod_dumb_mastervolume)
EXTERN_CVAR(Float, fluid_gain)
CVAR(Bool, mus_calcgain, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) // changing this will only take effect for the next song.
CVAR(Bool, mus_calcgain, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) // changing this will only take effect for the next song.
CVAR(Bool, mus_usereplaygain, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) // changing this will only take effect for the next song.
CUSTOM_CVAR(Float, mus_gainoffset, 0.f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) // for customizing the base volume
{
@ -214,6 +217,9 @@ static bool S_StartMusicPlaying(ZMusic_MusicStream song, bool loop, float rel_vo
I_SetRelativeVolume(saved_relative_volume * factor);
}
ZMusic_Stop(song);
// make sure the volume modifiers update properly in case replay gain settings have changed.
fluid_gain.Callback();
mod_dumb_mastervolume.Callback();
if (!ZMusic_Start(song, subsong, loop))
{
return false;
@ -488,6 +494,8 @@ static void CheckReplayGain(const char *musicname, EMidiDevice playertype, const
{
mus_playing.replayGain = 0.f;
mus_playing.replayGainFactor = dBToAmplitude(mus_gainoffset);
fluid_gain.Callback();
mod_dumb_mastervolume.Callback();
if (!mus_usereplaygain) return;
FileReader reader = mus_cb.OpenMusic(musicname);

View file

@ -41,6 +41,7 @@
#include "version.h"
#include <zmusic.h>
EXTERN_CVAR(Bool, mus_usereplaygain)
//==========================================================================
//
// ADL Midi device
@ -122,7 +123,16 @@ CUSTOM_CVAR(String, fluid_patchset, GAMENAMELOWERCASE, CVAR_ARCHIVE | CVAR_GLOBA
CUSTOM_CVAR(Float, fluid_gain, 0.5, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_VIRTUAL)
{
FORWARD_CVAR(fluid_gain);
if (!mus_usereplaygain)
{
FORWARD_CVAR(fluid_gain);
}
else
{
// Replay gain will disable the user setting for consistency.
float newval;
ChangeMusicSetting(zmusic_fluid_gain, mus_playing.handle, 0.5f, & newval);
}
}
CUSTOM_CVAR(Bool, fluid_reverb, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_VIRTUAL)
@ -493,6 +503,14 @@ CUSTOM_CVAR(Int, mod_autochip_scan_threshold, 12, CVAR_ARCHIVE | CVAR_GLOBAL
CUSTOM_CVAR(Float, mod_dumb_mastervolume, 1.f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_VIRTUAL)
{
FORWARD_CVAR(mod_dumb_mastervolume);
if (!mus_usereplaygain)
{
FORWARD_CVAR(mod_dumb_mastervolume);
}
else
{
float newval;
ChangeMusicSetting(zmusic_mod_dumb_mastervolume, mus_playing.handle, 0.5f, &newval);
}
}