From: James Courtier-Dutton <James@superbug.co.uk>
To: Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel@lists.sourceforge.net
Subject: Re: [RFC] TLV entry for linear volume
Date: Fri, 25 Aug 2006 17:27:12 +0100 [thread overview]
Message-ID: <44EF24E0.3080802@superbug.co.uk> (raw)
In-Reply-To: <s5hsljl866g.wl%tiwai@suse.de>
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
next prev parent reply other threads:[~2006-08-25 16:27 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-23 13:52 [RFC] TLV entry for linear volume Takashi Iwai
2006-08-23 15:07 ` James Courtier-Dutton
2006-08-23 15:31 ` Takashi Iwai
2006-08-23 17:09 ` Takashi Iwai
2006-08-23 18:22 ` James Courtier-Dutton
2006-08-23 18:34 ` Takashi Iwai
2006-08-23 23:48 ` James Courtier-Dutton
2006-08-24 9:16 ` Takashi Iwai
2006-08-25 10:23 ` Takashi Iwai
2006-08-25 16:27 ` James Courtier-Dutton [this message]
2006-08-28 10:00 ` Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=44EF24E0.3080802@superbug.co.uk \
--to=james@superbug.co.uk \
--cc=alsa-devel@lists.sourceforge.net \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.