[alsa-devel] Controling wave amplitude using alsa api !! (pcm interface ???????)

Guilherme Longo grlongo.ireland at gmail.com
Wed Aug 5 13:35:49 CEST 2009


Hi again.

I've got half of my work done with it. I found the values of the samples 
been analyzed, **BUT* *it is given in a strange unity!

while (count-- > 0) {
                 res = sin(phase) * 15000;
                 ires.i = res;
                 tmp = ires.c;
               * printf("som -> %g\n", res);  // Here I get the values*
                 for (chn = 0; chn < channels; chn++) {
                        for (byte = 0; byte < (unsigned int)bps; byte++)
                                 *(samples[chn] + byte) = tmp[1];
                                  samples[chn] += steps[chn];
                 }

Now, how can I transform this samples in a more human understandable 
notation as in Db unity for example?
Is there any alsa api function to control it? Should I use the mixer  
interface somehow?

This is the output:

som -> 11976.3
som -> 11387
som -> 10752.9
som -> 10076.6
som -> 9360.7
som -> 8608.02
som -> 7821.53
som -> 7004.31
som -> 6159.56
som -> 5290.63
som -> 4400.9
som -> 3493.89
som -> 2573.15
som -> 1642.3
som -> 704.996
som -> -235.076
som -> -1174.22
som -> -2108.76
som -> -3035.01
som -> -3949.33
som -> -4848.14
som -> -5727.91

Thanks!
Guilherme Longo wrote:
> Hi all!
>
> Mates, I am following the example PCM.C that I found at alsa web site. 
> its a sine wave generator.
> I am looking for a control that alsa provides to control the amplitude 
> of the wave.
>
> As I could found so for, there is just frequency control... I didn't 
> find any amplitude control.
>
> * I don't want to control the volume using alsamixer or even my 
> sound... I want to generate a wave with predefined amplitude.
>
> Does anyone could give me a little help??
>
> Thanks a lot!
>
>


More information about the Alsa-devel mailing list