On July 26, 2010 09:07:35 pm you wrote:
Sure, NP I'll take a look.
Good news!
As I mentioned in a follow-up to another thread, I found a bunch
more dB related functions.
I tested replacing the code in volume.c:dac_volume_to_db() and
adc_volume_to_db() with a call to ALSA's snd_ctl_convert_to_dB().
The results are identical! And better for ADC compatibility, right?
Now comes the fun part. Coming up with an Al-Gore-rithm to
handle the scale markings using these ALSA functions -
how many 6dB steps we have, which ones to display, the range, etc.
It occurred to me 'dynamic markings': If the user expands
more, or less, vertically, then more, or less, markings should appear.
But it's still tricky - we want it to look the way I suggested above,
with more markings concentrated around the 0dB point, whenever
we are forced to compromise by removing marks.
Ultimately, at minimum height it must look like that - it's a compromise,
until a (better) solution comes up.
Also I see there is something called TLV based dB conversion where
I think it's a table or can be an arbitrary function. Must study more.
------------
For now here's the code, throw it inside
dac_volume_to_db() and
adc_volume_to_db() but *replace* DAC_VOLUME_NAME with ADC_VOLUME_NAME,
and I believe mixer_volume_to_db() and wherever else required.
Do you need a patch?
Hope this is OK, not sure how many members to set in struct snd_ctl_elem_id.
List members, does it look OK?
char* dac_volume_to_db(int ival) {
if (ival != 0) {
// Use ALSA functions to get dB values.
long db_gain = 0;
float fval;
snd_ctl_elem_id_t *elem_id;
snd_ctl_elem_id_alloca(&elem_id);
snd_ctl_elem_id_clear(elem_id);
snd_ctl_elem_id_set_interface(elem_id, SND_CTL_ELEM_IFACE_MIXER);
snd_ctl_elem_id_set_name(elem_id, DAC_VOLUME_NAME);
snd_ctl_convert_to_dB(ctl, elem_id, ival, &db_gain);
fval = ((float)db_gain / 100.0);
sprintf(temp_label, "%+2.1f", fval);
return (temp_label) ;
}
else
{
// Rest of function ('off' part). ]
...
Tim.
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@lists.linuxaudio.org
http://lists.linuxaudio.org/listinfo/linux-audio-dev
LINUX® is a registered trademark of Linus Torvalds in the USA and other countries.
Linuxaudio.org logo copyright Thorsten Wilms © 2006.
Hosting provided by the Virginia Tech Department of Music and DISIS.