[alsa-devel] Create a stereo sound with alsa
Clemens Ladisch
clemens at ladisch.de
Sat Jul 28 11:36:08 CEST 2012
Luca Longhi wrote:
> Hi. I've written a code to play two different sine wave (same amplitude and
> f1=440Hz f2=600Hz) one on the left channel and the other on the right
> channel. It seems to be working. I've tried doing the same thing using two
> different sounds file (stereo) but the result is wrong.
> err=snd_pcm_hw_params_set_format(handle, params, SND_PCM_FORMAT_S16_LE); //16bit per campione=2byte per campione
> ...
> char * buffer1;
> char * buffer2;
> char * risultato;
> ...
> {v1=buffer1[j1];}
> {v2=buffer2[j2];}
> risultato[i++]=v1;
> risultato[i++]=v2;
The device expects 16-bit samples, but you write 8-bit values.
Regards,
Clemens
More information about the Alsa-devel
mailing list