[Speex-dev] Is it possible to mix encoded audio?

Fabio fabpet at gmail.com
Mon Jun 6 04:08:56 PDT 2005


Hi to all,

I developed a VoIP application using Speex. Now i want to record the
conversation to a file.
As i have two indipendent thread transmitting e receiving voice i
whish to mix both audio streams in one stream before saving the
conversation to a file.

I'm using Speex in narrow band mode, 8 bits per sample, mono.

i found at this link

http://www.vttoth.com/digimix.htm 

a simple way to mix audio:

".........Let's say we have two signals, A and B. If A is quiet, we
want to hear B on the output in unaltered form. If B is quiet, we want
to hear A on the output (i.e., A and B are treated symmetrically.) If
both A and B have a non-zero amplitude, the mixed signal must have an
amplitude between the greater of A and B, and the maximum permissible
amplitude.
....................
In a practical implementation, the signal values are not between 0 and
1, but between 0 and some maximum integer value, such as 255 for 8-bit
signals. So the equation needs to be normalized. For 8-bit audio, the
normalized version looks like this:

    Z = A + B - A·B / 256

When I tested this mixing method, I got the expected result: as I
mixed multiple audio streams I heard the contributing signals clearly,
without distortion or loss of volume......."

This kind of argument is applicable to Speex encoded audio or i have
to decode audio first, mix the two streams and the re-encode it?

Best regard 
Fabio


More information about the Speex-dev mailing list