]> git.sesse.net Git - vlc/commitdiff
aout: map software volume as cubic root of amplification factor
authorRémi Denis-Courmont <remi@remlab.net>
Tue, 26 Jul 2011 16:47:13 +0000 (19:47 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Tue, 26 Jul 2011 16:47:13 +0000 (19:47 +0300)
Also scale maximum down to 2 times the nominal volume (i.e. +18dB) to
stay in the recommended range of +10 to +20dB.

include/vlc_aout_intf.h
src/audio_output/output.c

index 8b630a175a545ad1ec1abb5a1582fd2358a83bbf..63dc2631a84281cfdc8e3d397eaf4f7c9cab8a6b 100644 (file)
@@ -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))
index 4a2449bf55e6a38e12b03be63f19a82100ae865a..bde8f10872152a751345e180ec269053d6ffea31 100644 (file)
@@ -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;
 }