[alsa-devel] Create a stereo sound with alsa
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. Obviously I've played the sounds file separately and the result is correct. I think that the problem is the configuration of the pcm. Could you give me some advice? The code is attached. If you want I'll send you the sound files. Regards.
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
participants (2)
-
Clemens Ladisch
-
Luca Longhi