Re: [RFC] TLV entry for linear volume

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

 



Takashi Iwai wrote:
> At Thu, 24 Aug 2006 11:16:45 +0200,
> I wrote:
>   
>> 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.
>>     
>
> The below is the latest version I have on my local tree.
> It's against HG tree.
>
>
> Takashi
>   
+#ifndef HAVE_SOFT_FLOAT
+    case SND_CTL_TLVT_DB_LINEAR: {
+        int mindb = rec->db_info[2];
+        int maxdb = rec->db_info[3];
Maybe I am unclear about what rec->min is, but I though that it was the 
lowest value the volume(old % scale) could be.
So, what exactly is this section trying to do? Just handling error cases?
+        if (volume <= rec->min || rec->max <= rec->min)
+            *db_gain = mindb;
+        else if (volume >= rec->max)
+            *db_gain = maxdb;
+        else {

This makes sense. (part A), when combined with (part B)
+            double val = (double)(volume - rec->min) /
+                (double)(rec->max - rec->min);

This special case is for when mindb = negative infinity.
+            if (mindb <= SND_CTL_TLV_DB_GAIN_MUTE)
+                *db_gain = (long)(100.0 * 20.0 * log10(val)) +
+                    maxdb;
+            else {

This makes sense. (Part B) when combined with (Part A)
It covers a good general case of mapping (linear_min...linear_max) onto 
(dB_min...dB_max)
+                /* FIXME: precalculate and cache these values */
+                double lmin = pow(10.0, mindb/20.0);
+                double lmax = pow(10.0, maxdb/20.0);
+                val = (lmax - lmin) * val + lmin;
+                *db_gain = (long)(100.0 * 20.0 * log10(val));
+            }
+        }
+        return 0;
+    }
+#endif


Summary, I am happy with this now.

James


-------------------------------------------------------------------------
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