Re: [LAD] Regarding amplifying a PCM frame

From: Drip Stone <dripstone.blendercn@email-addr-hidden>
Date: Tue Oct 27 2009 - 02:50:15 EET

Hello again,

I obtain data for fbuffer in following way:
    char *fbuffer = ( char * ) malloc ( 10240000 ); //10M bytes
    long length = fread ( fbuffer, 1, 10240000, file );

I also set alsa in float mode:
    snd_pcm_hw_params_set_format ( handle, params,

     SND_PCM_FORMAT_FLOAT_LE );

I pasted all the code at http://pastebin.com/m7fdf0957.

Thank you,
Dripstone

On Mon, Oct 26, 2009 at 3:59 PM, Jens M Andreasen
<jens.andreasen@email-addr-hiddenwrote:

> Nothing in the posted code fragment suggests that neither in nor out is
> remotely related to floats. Where do you get yor in-data from? Why is
> fbuffer[] a bytearray (if that is what it is?) How was ALSA opened?
>
>
> /j
>
> On Mon, 2009-10-26 at 15:05 -0700, Drip Stone wrote:
>
> > 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@email-addr-hidden-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@email-addr-hidden
> > http://lists.linuxaudio.org/mailman/listinfo/linux-audio-dev
> >
> >
> > _______________________________________________
> > Linux-audio-dev mailing list
> > Linux-audio-dev@email-addr-hidden
> > http://lists.linuxaudio.org/mailman/listinfo/linux-audio-dev
>
>

_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/mailman/listinfo/linux-audio-dev
Received on Tue Oct 27 04:15:03 2009

This archive was generated by hypermail 2.1.8 : Tue Oct 27 2009 - 04:15:03 EET