-
Notifications
You must be signed in to change notification settings - Fork 20
Description
From BMO 1746799 https://bugzilla.mozilla.org/show_bug.cgi?id=1746799
Per https://freedesktop.org/software/pulseaudio/doxygen/volume.html (my italics)
The volumes in PulseAudio are cubic in nature and applications shouldn't perform calculations with them directly. Instead, they should be converted to and from either dB or a linear scale:
dB - pa_sw_volume_from_dB() / pa_sw_volume_to_dB() Linear - pa_sw_volume_from_linear() / pa_sw_volume_to_linear()For simple multiplication, pa_sw_volume_multiply() and pa_sw_cvolume_multiply() can be used.
It's often unknown what scale hardware volumes relate to. Don't use the above functions on sink and source volumes, unless the sink or source in question has the PA_SINK_DECIBEL_VOLUME or PA_SOURCE_DECIBEL_VOLUME flag set. The conversion functions are rarely needed anyway, most of the time it's sufficient to treat all volumes as opaque with a range from PA_VOLUME_MUTED (0%) to PA_VOLUME_NORM (100%).
cubeb does use pa_sw_volume_from_linear() on source volumes, and the result is that even a very low setting of volume through cubeb (e.g 0.02) results in a quite loud volume.
In contrast, pulseaudio's own volume control does just map from PA_VOLUME_MUTED to PA_VOLUME_NORM without using volume_from_linear() -- https://gitlab.freedesktop.org/pulseaudio/pavucontrol/-/blob/master/src/channelwidget.cc#L42