[alsa-devel] wrong decibel data?
Colin Guthrie
gmane at colin.guthr.ie
Tue Jun 8 17:30:40 CEST 2010
'Twas brillig, and Raymond Yau at 08/06/10 01:47 did gyre and gimble:
>> Here is the function in PA's pulse/volume.c:
>>
>> pa_volume_t pa_sw_volume_from_linear(double v) {
>>
>> if (v <= 0.0)
>> return PA_VOLUME_MUTED;
>>
>> /*
>> * We use a cubic mapping here, as suggested and discussed here:
>> *
>> * http://www.robotplanet.dk/audio/audio_gui_design/
>> *
>>
>> http://lists.linuxaudio.org/pipermail/linux-audio-dev/2009-May/thread.html#23151
>> *
>> * We make sure that the conversion to linear and back yields the
>> * same volume value! That's why we need the lround() below!
>> */
>>
>> return (pa_volume_t) lround(cbrt(v) * PA_VOLUME_NORM);
>> }
>>
>>
> can you provide the forumla for the "Master" volume control of pulse device
> ? ctl.pulse
>
> there are 65536 steps ,
> where are 0dB , -6dB and -inf dB on this cubic mapping ?
Well 0 dB and -inf dB are obvious: 100% and 0% respectively.
-6dB is about 80%:
1. Convert to Linear:
10 ^ (-6 / 20.0) = 10 ^ -0.3 = 0.501187
2. Cube Root:
0.7943
Here is the code from volume.c that does this (combined with the
function already pasted above). It's probably easier just to follow the
code rather than have me describe it (no doubt poorly!):
static double dB_to_linear(double v) {
return pow(10.0, v / 20.0);
}
pa_volume_t pa_sw_volume_from_dB(double dB) {
if (isinf(dB) < 0 || dB <= PA_DECIBEL_MININFTY)
return PA_VOLUME_MUTED;
return pa_sw_volume_from_linear(dB_to_linear(dB));
}
The final stage in pa_sw_volume_from_linear() (the * by PA_VOLUME_NORM
and the lround()) is just converting to PA's own internal representation.
HTHs
Just for clarity, the reverse of for my approximate cut off at 16% would be:
16% = 0.16
0.16 ^ 3 = 0.004096
20 * log(0.004096) = -47.75dB
Col
--
Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/
Day Job:
Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
Mandriva Linux Contributor [http://www.mandriva.com/]
PulseAudio Hacker [http://www.pulseaudio.org/]
Trac Hacker [http://trac.edgewall.org/]
More information about the Alsa-devel
mailing list