All of lore.kernel.org
 help / color / mirror / Atom feed
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: Wed, 23 Aug 2006 19:22:37 +0100	[thread overview]
Message-ID: <44EC9CED.8040408@superbug.co.uk> (raw)
In-Reply-To: <s5hwt8zwf96.wl%tiwai@suse.de>

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)
I.e. the offset taken before the log10 operation, not afterwards as is 
shown in your code:
*db_gain = (long)(100.0 * 20.0 *
                      log10((double)(volume - rec->min) /
                        (double)(rec->max - rec->min)));
*db_gain += maxdb;

Then check the equation by finding the linear value that equates to:
0dB, so that ((linear / scale) - offset) == 1 * original signal voltage
6dB, so that ((linear / scale) - offset) == 2 * original signal voltage
-6dB, so that ((linear / scale) - offset) == 0.5 * original signal voltage

This is assuming that the linear values affect the voltage, and not the 
power.

So, you need to pass from driver to userspace the value of "scale" and 
"offset", together with maybe one bit to identify if the minimum value 
of the "linear" is mute or not.

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

  reply	other threads:[~2006-08-23 18:22 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 [this message]
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
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=44EC9CED.8040408@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.