[alsa-devel] Mixer volume/decibel mapping
clemens at ladisch.de
Fri May 21 11:56:22 CEST 2010
Peter Ujfalusi wrote:
> On Friday 21 May 2010 09:35:31 ext Clemens Ladisch wrote:
> > James Courtier-Dutton wrote:
> > > I believe it could be extended to support a continuous range.
> > > For example, some hardware uses a 32bit value to control the gain.
> > > The mix operation is simply "the_sample" * "the_control_value".
> > > So in this case the hardware has a linear control that can be
> > > considered continuous for our purposes.
> > Such controls already exist:
> > $ grep -rl DB_LINEAR sound/
> > ...
> The DB_SCALE also provides linear mapping:
> For example, if the HW volume control has a range 0 .. 100
> In HW these means:
> 0 == -10dB, 1 == -9.8dB, 2 == -9.6dB .. 99 = 9.8dB, 100 = 10dB
> So it is linear.
This is not what is meant by "linear", because dB values are not linear.
DB_LINEAR means that the mixer control value is a multiplier for the
PCM sample value, as James wrote. A DB_LINEAR mapping has
0 == -infinity dB, full scale == 0 dB, and the mapping between mixer
control values and corresponding dB values it _not_ linear.
TLV_DB_LINEAR_ITEM is a quite misleading name, but it actually means
"dB mapping for a mixer control whose value has a linear effect on the
sound output", _not_ a linear value <-> dB mapping.
More information about the Alsa-devel