Re: [linux-audio-dev] sophomore questions

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [linux-audio-dev] sophomore questions
From: Simon Per Soren Kagedal (simon_AT_cs.uoregon.edu)
Date: Wed Apr 04 2001 - 01:21:15 EEST


On Tue, Apr 03, 2001 at 05:59:55AM -0600, ljp wrote:
> If I do this
>
> read( sd, inbuffer, BUFSIZE);
>
> for( i=0;i<BUFSIZE;i++) {
> leftBuf=(inbuffer[2*i] * gain);
>
> }
>
> would I do this?
> write( file_d, leftBuf, BUFSIZE/2);
>
> to write a mono file?

Basically, yes, minus some bugs (overflowing the inbuffer...).

short inbuffer[BUFSIZE], leftBuf[BUFSIZE/2]; /* or whatever type
                                                   you have */
read (sd, inbuffer, BUFSIZE);
for (i=0; i<BUFSIZE/2; i++)
        leftBuf[i] = inbuffer[2*i] * gain;
write (file_d, leftBuf, BUFSIZE/2);

> Some code I am working with does this.
>
> read( sd, inbuffer, BUFSIZE*2)/2;
>
> What would be the advantage of doing this?

I don't really see what you mean but sure, of course you could as well
in the above example change BUFSIZE to BUFSIZE*2 and BUFSIZE/2 to
BUFSIZE... Doesn't really matter. :)

Simon.


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Sat Apr 07 2001 - 15:59:45 EEST