On Mon, 2009-10-26 at 15:05 -0700, Drip Stone wrote:
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?
Ouch, you're doing a byte-by-byte copy of a 32bit float?? Please, just
use the correct data types.
Floating point audio data is usually signed, so -1.0 and 1.0 are the
farthest extents, and 0.0 would be the default no-signal state.
Peter.