[vlc-commits] aout: map software volume as cubic root of amplification factor

Rémi Denis-Courmont git at videolan.org
Tue Jul 26 18:51:48 CEST 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Jul 26 19:47:13 2011 +0300| [03eac5247fb4d1377ae9ab248f8f2f6b508fcdbb] | committer: Rémi Denis-Courmont

aout: map software volume as cubic root of amplification factor

Also scale maximum down to 2 times the nominal volume (i.e. +18dB) to
stay in the recommended range of +10 to +20dB.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=03eac5247fb4d1377ae9ab248f8f2f6b508fcdbb
---

 include/vlc_aout_intf.h   |    2 +-
 src/audio_output/output.c |   14 +++++++++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/include/vlc_aout_intf.h b/include/vlc_aout_intf.h
index 8b630a1..63dc263 100644
--- a/include/vlc_aout_intf.h
+++ b/include/vlc_aout_intf.h
@@ -27,7 +27,7 @@
  */
 
 #define AOUT_VOLUME_DEFAULT             256
-#define AOUT_VOLUME_MAX                 1024
+#define AOUT_VOLUME_MAX                 512
 
 VLC_API audio_volume_t aout_VolumeGet( vlc_object_t * );
 #define aout_VolumeGet(a) aout_VolumeGet(VLC_OBJECT(a))
diff --git a/src/audio_output/output.c b/src/audio_output/output.c
index 4a2449b..bde8f10 100644
--- a/src/audio_output/output.c
+++ b/src/audio_output/output.c
@@ -283,7 +283,19 @@ void aout_VolumeNoneInit (audio_output_t *aout)
 static int aout_VolumeSoftSet (audio_output_t *aout, float volume, bool mute)
 {
     vlc_assert_locked (&aout->lock);
-    aout->mixer_multiplier = mute ? 0. : volume;
+
+    /* Cubic mapping from software volume to amplification factor.
+     * This provides a good tradeoff between low and high volume ranges.
+     *
+     * This code is only used for the VLC software mixer. If you change this
+     * formula, be sure to update the aout_VolumeHardInit()-based plugins also.
+     */
+    if (!mute)
+        volume = volume * volume * volume;
+    else
+        volume = 0.;
+
+    aout->mixer_multiplier = volume;
     return 0;
 }
 



More information about the vlc-commits mailing list