On 6 July 2013 07:04, Paul D. DeRocco <pdero...@ix.netcom.com> wrote:
> A few months ago, Clemens was kind enough to explain how to set a volume
> control, given its name, using the snd_ctl_elem_value_xxx functions. By
> experimenting on my Ubuntu system, it appeared that values from 0 to 0xFFFF
> ran the master volume through its entire range, as shown by having alsamixer
> running at the same time.
>
> Now, I run the same code on an embedded board, and it's always maxed out, or
> off at the bottom. I used "alsactl store" on both systems, and the master
> volume entries on both systems are identical, specifying a range of '0 -
> 64', a dbmin of -6400 and a dbmax of 0. (I assume those are really
> millibels.)
>
> So how does one programmatically find the range of a control? I'd prefer to
> have plain linear voltage control, but I'll take anything I can get as long
> as I know what the shape of the curve is.
>

While you might think that the mixer control API would be simple,
unfortunately it is not.
A browse through the alsamixer source code will show you that.
A good start is to run
"amixer contents"
For each control is gives:
numid=1,iface=MIXER,name='Headphone Playback Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=87,step=0
  : values=87,87
  | dBscale-min=-65.25dB,step=0.75dB,mute=0

The hardware is written with INTEGER values.
There are 2 values (a stereo control, 1 for left, 1 for right)
The min value that is valid is 0.
The max value that is valid is 87
The step size is not defined in this example. I.e. It is 1 so you can
wright values 0,1,2,3,...85,86,87  but not 88.
Some alsa drivers (not all yet) also provide metadata that allows one
to convert from the INTEGER value to dB value.
The dB values are mostly only used to display to the user as they are
better understood by the user.
There is an alsa API to convert from integer to db, and from db to integer.
For the conversion, the STEP value is important.
For example, you can set a dB of -65.25 but you cannot set a value of -65.00
For the API, the dB values are
(integer_value_returned_from_the_API_call / 100) in order to avoid
floating point.

Does this help?

Kind Regards

James

------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user

Reply via email to