Play multiple sounds concurrently

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hey,


I want to play multiple sounds concurrently with ALSA. The audio data is 
mono and G.711 a-law encoded. I can successfully play a single source of 
audio data but the sound is distorted when I try to play two sources.

Basically, this is what I'm doing:

-----8<-----------------
char buf1[1024];    // filled with audio data from source 1
char buf2[1024];    // filled with audio data from source 2
char wr_buf[1024];

for (int count = 0; count < 1024; count++)
   wr_buf[count] = (char) (0.5 * buf1[count]) +
                   (char) (0.5 * buf2[count]);

snd_pcm_writei(dev_handle, wr_buf, 1024);
-----8<-----------------


I think I have to use a scale value to correct the values or else 
clipping occures. However, this is the problem. How do I have to modify 
the audio bytes in order to add them together and write them into one 
buffer?




greetings..
..Markus
_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux