[vlc-commits] aout: add --gain to control gain regardless of output module
Rémi Denis-Courmont
git at videolan.org
Wed Jul 18 20:48:45 CEST 2012
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Jul 18 21:47:45 2012 +0300| [dcf3f71b3b48090881f8deab305cc31ea1067ca3] | committer: 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).
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=dcf3f71b3b48090881f8deab305cc31ea1067ca3
---
src/audio_output/volume.c | 26 ++++++++++++++++++--------
src/libvlc-module.c | 6 ++++++
2 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/src/audio_output/volume.c b/src/audio_output/volume.c
index afb7e67..791154e 100644
--- a/src/audio_output/volume.c
+++ b/src/audio_output/volume.c
@@ -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,22 +164,33 @@ static float aout_ReplayGainSelect(vlc_object_t *obj, const char *str,
}
/* */
- if (mode == AUDIO_REPLAY_GAIN_MAX)
- return 1.;
+ float multiplier;
- if (replay_gain->pb_gain[mode])
- gain = replay_gain->pf_gain[mode]
- + var_InheritFloat (obj, "audio-replay-gain-preamp");
+ if (mode == AUDIO_REPLAY_GAIN_MAX)
+ {
+ multiplier = 1.f;
+ }
else
- gain = var_InheritFloat (obj, "audio-replay-gain-default");
+ {
+ float gain;
- float multiplier = pow (10., gain / 20.);
+ if (replay_gain->pb_gain[mode])
+ gain = replay_gain->pf_gain[mode]
+ + var_InheritFloat (obj, "audio-replay-gain-preamp");
+ else
+ gain = var_InheritFloat (obj, "audio-replay-gain-default");
+
+ 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;
}
diff --git a/src/libvlc-module.c b/src/libvlc-module.c
index a20f0c1..4c64b6b 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -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 )
More information about the vlc-commits
mailing list