From: Markus Luttenberger <m.luttenberger@avibit.com>
To: alsa-devel@alsa-project.org
Subject: Play multiple sounds concurrently
Date: Fri, 18 Dec 2009 14:44:30 +0100 [thread overview]
Message-ID: <4B2B873E.6010906@avibit.com> (raw)
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
next reply other threads:[~2009-12-18 13:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-18 13:44 Markus Luttenberger [this message]
2009-12-18 14:02 ` Play multiple sounds concurrently Clemens Ladisch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B2B873E.6010906@avibit.com \
--to=m.luttenberger@avibit.com \
--cc=alsa-devel@alsa-project.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.