Re: [RFC] TLV entry for linear volume

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At Thu, 24 Aug 2006 00:48:25 +0100,
James Courtier-Dutton wrote:
> 
> Takashi Iwai wrote:
> > At Wed, 23 Aug 2006 19:22:37 +0100,
> > James Courtier-Dutton wrote:
> >> Takashi Iwai wrote:
> >>> At Wed, 23 Aug 2006 17:31:10 +0200,
> >>> I wrote:
> >>>   
> >>>>> So, 0 dB is when (volume - rec->min) / (max - min) == 1
> >>>>> So, for +6 dB gain, the volume will need to be higher than max?
> >>>>> Does this sound right? In that case, maybe "max" is not a good name for 
> >>>>> it because volume can be greater than max.
> >>>>>       
> >>>> Hm, right, I didn't think of overload case with a linear volume
> >>>> codec.  By min and max, I thought of a "segment" between mute and
> >>>> 0dB (although not implemented rightly in alsa-lib).
> >>>>
> >>>> Maybe min and max should be in (0.01) dB expressions since the min and
> >>>> max "values" are known from snd_ctl_elem_info.  The only problem is
> >>>> that we have no standard definition of "mute" in dB expression.
> >>>> In alsa-lib, -9999999 indicates mute.  But it should be defined as a
> >>>> constant in a public header.
> >>>>     
> >>> It turned out that minimal dB makes the computation too complicated,
> >>> and chips are very likely from mute to a certain dB.  So, I decided to
> >>> drop the min dB there.
> >>>
> >>> The below are the revised patches.
> >>>
> >>>
> >>> Takashi
> >>>   
> >> I think you will find that your second approach is still wrong.
> >> You need to first identify the 0dB point, and then the scale factor and 
> >> offset value for the linear component before the log10 conversion.
> >> So, linear to log should be something like:
> >> 20log10 ((linear / scale) - offset)
> > 
> > What is linear and scale here?
> I explain that in the rest of my email.
> but I will repeat differently:
> "linear" is your X value that the hardware requires, that you say is a
> linear scale and not a log10 scale.
> "scale" is some multiplier to convert the integer X value into some
> floating point value. Together with an offset value to reach the correct
> 0db, +6dB and -6dB gain points.

But scale cannot be accurately expressed if the value range is small.
I don't think this manual calculation would make the programer
happier.

Actually, my assumption that the minimum value is always mute is
wrong.  There are real cases starting from non-mute.  Hence, passing
min_dB and max_dB is the best solution from the driver side.
It results in a little bit more computation in alsa-lib side in the
case min_dB != mute.  (When min_dB = mute, it's easy as I showed.)
min_dB != mute is anyway a rare case, and can be easily optimized by
precalculating the coefficients if necessary.


> > In my case, the calculation is so simple as below.
> > 
> > The value y at x [0,max] is
> > 
> >    y = (x / max) * maxVal
> > 
> > where maxVal = 10^(maxdB/20)
> > 
> > so, in dB expression,
> > 
> >   Y = 20 * log10(y) = 20 * log10((x / max) * 10^(maxdB/20))
> >     = 20 * log10(x/max) + maxdB
> > 
> > 
> > Takashi
> 
> It is unclear from your equation where the 0dB point is.

0dB point doesn't have to be defined strictly.  See below.

> From your equation, when x = max( i.e. what I would expect to be the 0dB
> point as a result of comments by you in previous emails), one reaches
> the maxdB point, and not the 0dB point. Getting the 0dB point on the
> log10 curve is very important, otherwise the conversion from linear to
> dB occurs at the wrong point on the log10 curve, resulting in the dB
> values all being wrong.

Sorry but how bad?  Put values in the real word there.

As a counter example to your case, imagine a volume range from +1dB to
+15dB in [0, 255].  This is a preamp and routed only when a switch is
on, so no 0dB crossing.  How would you calculate the 0dB point and how
would you express it in integer?

The difference between us is just how to express and pass the
coefficeints.  My suggestion is to pass the values given in the
datasheet as they are, min and max dB.


Takashi

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/alsa-devel

[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux