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.