Commit dcf3f71b authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

aout: add --gain to control gain regardless of output module

This linear gain works also for outputs with native volume or without
volume. (Obviously though, it does not work for digital pass-through).
parent bf1ee347
......@@ -145,7 +145,6 @@ int aout_volume_Amplify(aout_volume_t *vol, block_t *block)
static float aout_ReplayGainSelect(vlc_object_t *obj, const char *str,
const audio_replay_gain_t *replay_gain)
{
float gain = 0.;
unsigned mode = AUDIO_REPLAY_GAIN_MAX;
if (likely(str != NULL))
......@@ -165,8 +164,15 @@ static float aout_ReplayGainSelect(vlc_object_t *obj, const char *str,
}
/* */
float multiplier;
if (mode == AUDIO_REPLAY_GAIN_MAX)
return 1.;
{
multiplier = 1.f;
}
else
{
float gain;
if (replay_gain->pb_gain[mode])
gain = replay_gain->pf_gain[mode]
......@@ -174,13 +180,17 @@ static float aout_ReplayGainSelect(vlc_object_t *obj, const char *str,
else
gain = var_InheritFloat (obj, "audio-replay-gain-default");
float multiplier = pow (10., gain / 20.);
multiplier = pow (10., gain / 20.);
}
if (replay_gain->pb_peak[mode]
&& var_InheritBool (obj, "audio-replay-gain-peak-protection")
&& replay_gain->pf_peak[mode] * multiplier > 1.0)
multiplier = 1.0f / replay_gain->pf_peak[mode];
/* Command line / configuration gain */
multiplier *= var_InheritFloat (obj, "gain");
return multiplier;
}
......
......@@ -149,6 +149,10 @@ static const char *const ppsz_snap_formats[] =
#define MONO_LONGTEXT N_("This will force a mono audio output.")
#endif
#define GAIN_TEXT N_("Audio gain")
#define GAIN_LONGTEXT N_( \
"Thus linear gain will be applied to outputted audio.")
#define VOLUME_TEXT N_("Default audio volume")
#define VOLUME_LONGTEXT N_( \
"You can set the default audio output volume here.")
......@@ -1470,6 +1474,8 @@ vlc_module_begin ()
add_bool( "audio", 1, AUDIO_TEXT, AUDIO_LONGTEXT, false )
change_safe ()
add_float( "gain", 1., GAIN_TEXT, GAIN_LONGTEXT, true )
change_float_range( 0., 8. )
add_integer_with_range( "volume", AOUT_VOLUME_DEFAULT, 0,
AOUT_VOLUME_MAX, VOLUME_TEXT,
VOLUME_LONGTEXT, false )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment