[LAD] Regarding amplifying a PCM frame

Drip Stone dripstone.blendercn at gmail.com
Mon Oct 26 22:05:37 UTC 2009


Hi,

Thank you for providing valuable information. I will put some code here:

    while ( 1 )
    {
        for ( int i = 0; i < frames; i++ )
        {
            float t = 0;
            if ( left )    //for left channel
            {
                t = *((float*)&(fbuffer[pos+i*4]));    //4 bytes each frame
                t*=2;
                //printf("%f ",t);
                for ( int j = 0; j < 4; j++ )
                    buffer[i*8+j] = ((char*)&t)[j];    //8 bytes for 2
channels
            }

        rc = snd_pcm_writei ( handle, buffer, frames );
        pos += frames * 4;
    }

I think the value is not out of [-1.0,1.0]. BTW, what does it mean when a
value is negative?


Best,
Dripstone

2009/10/26 Jörn Nettingsmeier <nettings at folkwang-hochschule.de>

> On 10/26/2009 11:38 AM, Victor Lazzarini wrote:
> > Well if the audio was clipped, there would probably be some audible
> > distortion.
> > Perhaps if a code fragment was posted we could give a more informed
> > opinion.
>
> i was thinking of operating on files, where clamping can be done with
> perfect fidelity. but i may have misunderstood the OP.
>
> _______________________________________________
> Linux-audio-dev mailing list
> Linux-audio-dev at lists.linuxaudio.org
> http://lists.linuxaudio.org/mailman/listinfo/linux-audio-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxaudio.org/pipermail/linux-audio-dev/attachments/20091026/03d9813c/attachment.html>


More information about the Linux-audio-dev mailing list