[alsa-devel] wrong decibel data?
Raymond Yau
superquad.vortex2 at gmail.com
Thu Jun 10 05:16:37 CEST 2010
2010/6/8 Colin Guthrie <gmane at colin.guthr.ie>
> '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
>
>
Can you explain how PA handle the volume controls of ac97 codec ?
PCM -34.5dB to +*12* dB
Master -46.5dB to 0dB
The total dB range (PCM + MASTER) is -81dB to +*12*dB
Most user concern about recording without distrotion. (i.e. best result when
Capture Volume at 0dB , PCM and Master Volume at 0dB ) and they need where
are 0dB points
More information about the Alsa-devel
mailing list