DSPRelated.com
Forums

Combining G711 streams

Started by kevinmr August 7, 2003
Hi, I have two streams of G711 coming into my process. I have a need
to combine the streams and write the result to a file. Is this
possible? Any ideas would be appreciated.

KR
kevinmr wrote:
> > Hi, I have two streams of G711 coming into my process. I have a need > to combine the streams and write the result to a file. Is this > possible? Any ideas would be appreciated.
Well G711 is just u-law encoded and the AU file format supports interleaved stereo u-law files. Thats probably your best bet. Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo nospam@mega-nerd.com (Yes it's valid) +-----------------------------------------------------------+ "The beauty of religious mania is that it has the power to explain everything. Once God (or Satan) is accepted as the first cause of everything which happens in the mortal world, nothing is left to chance...logic can be happily tossed out the window." - Stephen King
Erik de Castro Lopo wrote:

> kevinmr wrote: >> >> Hi, I have two streams of G711 coming into my process. I have a need >> to combine the streams and write the result to a file. Is this >> possible? Any ideas would be appreciated. > > Well G711 is just u-law encoded and the AU file format supports > interleaved stereo u-law files. Thats probably your best bet.
..or it could be A-Law. BTW, if "combining" means mixing them (adding them together) you'll have to decode them before you add. Regards -- Adrian Hey
Adrian Hey <ahey@NoSpicedHam.iee.org> wrote in message news:<bgvobn$3tk$1$8302bc10@news.demon.co.uk>...
> Erik de Castro Lopo wrote: > > > kevinmr wrote: > >> > >> Hi, I have two streams of G711 coming into my process. I have a need > >> to combine the streams and write the result to a file. Is this > >> possible? Any ideas would be appreciated. > > > > Well G711 is just u-law encoded and the AU file format supports > > interleaved stereo u-law files. Thats probably your best bet. > > ..or it could be A-Law. BTW, if "combining" means mixing them > (adding them together) you'll have to decode them before you > add. > > Regards
G711 decode streams 1 & 2 -> Convolute -> G.711 encode stream -> file Vinod Rex
Sorry if I am not clear enough. I am not a DSP afficianado by any
stretch of the imagination. I have been given the task of handling two
G711 streams and need to write the streams to a file for recording
purposes. I know I can convert both streams to 16-bit linear (PCM?)
and average each sample and then convert back to G711 or I can create
a stereo wave file. I was hoping some smart guy had a quick way of
summing the streams without the intermediate stage of decoding to
16-bit linear.

KR

Adrian Hey <ahey@NoSpicedHam.iee.org> wrote in message news:<bgvobn$3tk$1$8302bc10@news.demon.co.uk>...
> Erik de Castro Lopo wrote: > > > kevinmr wrote: > >> > >> Hi, I have two streams of G711 coming into my process. I have a need > >> to combine the streams and write the result to a file. Is this > >> possible? Any ideas would be appreciated. > > > > Well G711 is just u-law encoded and the AU file format supports > > interleaved stereo u-law files. Thats probably your best bet. > > ..or it could be A-Law. BTW, if "combining" means mixing them > (adding them together) you'll have to decode them before you > add. > > Regards
Hi KR,

The G711 encoding process is nonlinear, so you cannot simply combine the two
encoded streams nicely.  Hence this is why the intermediate decoding step is
needed before combining the samples (e.g. adding the samples together and
scaling and handling overflows appropriately as you do so) before they can
be encoded again.

Note that this method is still non-linear and imperfect (since the
encoding/decoding process is not perfectly reversible, and also because
certain choices need to be made when adding the samples together to avoid
possibly nasty sounding overflows), but it is just not quite as non-linear
overall (i.e. it has a chance of still sounding fairly decent).

hth,
Steve

"kevinmr" <kevinmr@optonline.net> wrote in message
news:6a98a59b.0308081234.270776dd@posting.google.com...
> Sorry if I am not clear enough. I am not a DSP afficianado by any > stretch of the imagination. I have been given the task of handling two > G711 streams and need to write the streams to a file for recording > purposes. I know I can convert both streams to 16-bit linear (PCM?) > and average each sample and then convert back to G711 or I can create > a stereo wave file. I was hoping some smart guy had a quick way of > summing the streams without the intermediate stage of decoding to > 16-bit linear. > > KR > > Adrian Hey <ahey@NoSpicedHam.iee.org> wrote in message
news:<bgvobn$3tk$1$8302bc10@news.demon.co.uk>...
> > Erik de Castro Lopo wrote: > > > > > kevinmr wrote: > > >> > > >> Hi, I have two streams of G711 coming into my process. I have a need > > >> to combine the streams and write the result to a file. Is this > > >> possible? Any ideas would be appreciated. > > > > > > Well G711 is just u-law encoded and the AU file format supports > > > interleaved stereo u-law files. Thats probably your best bet. > > > > ..or it could be A-Law. BTW, if "combining" means mixing them > > (adding them together) you'll have to decode them before you > > add. > > > > Regards
Thanks to all who responded to my post. There are enough hinst and
suggestions in the responses to keep me busy for quite a while.

KR

"Steve Conahan" <sconahan@mathworks.com> wrote in message news:<bh125o$els$1@ginger.mathworks.com>...
> Hi KR, > > The G711 encoding process is nonlinear, so you cannot simply combine the two > encoded streams nicely. Hence this is why the intermediate decoding step is > needed before combining the samples (e.g. adding the samples together and > scaling and handling overflows appropriately as you do so) before they can > be encoded again. > > Note that this method is still non-linear and imperfect (since the > encoding/decoding process is not perfectly reversible, and also because > certain choices need to be made when adding the samples together to avoid > possibly nasty sounding overflows), but it is just not quite as non-linear > overall (i.e. it has a chance of still sounding fairly decent). > > hth, > Steve > > "kevinmr" <kevinmr@optonline.net> wrote in message > news:6a98a59b.0308081234.270776dd@posting.google.com... > > Sorry if I am not clear enough. I am not a DSP afficianado by any > > stretch of the imagination. I have been given the task of handling two > > G711 streams and need to write the streams to a file for recording > > purposes. I know I can convert both streams to 16-bit linear (PCM?) > > and average each sample and then convert back to G711 or I can create > > a stereo wave file. I was hoping some smart guy had a quick way of > > summing the streams without the intermediate stage of decoding to > > 16-bit linear. > > > > KR > > > > Adrian Hey <ahey@NoSpicedHam.iee.org> wrote in message > news:<bgvobn$3tk$1$8302bc10@news.demon.co.uk>... > > > Erik de Castro Lopo wrote: > > > > > > > kevinmr wrote: > > > >> > > > >> Hi, I have two streams of G711 coming into my process. I have a need > > > >> to combine the streams and write the result to a file. Is this > > > >> possible? Any ideas would be appreciated. > > > > > > > > Well G711 is just u-law encoded and the AU file format supports > > > > interleaved stereo u-law files. Thats probably your best bet. > > > > > > ..or it could be A-Law. BTW, if "combining" means mixing them > > > (adding them together) you'll have to decode them before you > > > add. > > > > > > Regards
kevinmr@optonline.net (kevinmr) 
>... > Sorry if I am not clear enough. I am not a DSP afficianado by any > stretch of the imagination. I have been given the task of handling two > G711 streams and need to write the streams to a file for recording > purposes. I know I can convert both streams to 16-bit linear (PCM?) > and average each sample and then convert back to G711 or I can create > a stereo wave file. I was hoping some smart guy had a quick way of > summing the streams without the intermediate stage of decoding to > 16-bit linear. > > KR >
G711 is a "type of floating point" encoding. You have a signal, exponent and a mantissa with implicit ones. You can take advantage of this to perform arithmetic operations. Luiz Carlos
Luiz Carlos wrote:
> > kevinmr@optonline.net (kevinmr) > >... > > Sorry if I am not clear enough. I am not a DSP afficianado by any > > stretch of the imagination. I have been given the task of handling two > > G711 streams and need to write the streams to a file for recording > > purposes. I know I can convert both streams to 16-bit linear (PCM?) > > and average each sample and then convert back to G711 or I can create > > a stereo wave file. I was hoping some smart guy had a quick way of > > summing the streams without the intermediate stage of decoding to > > 16-bit linear. > > > > KR > > > > G711 is a "type of floating point" encoding. You have a signal, > exponent and a mantissa with implicit ones. You can take advantage of > this to perform arithmetic operations. > > Luiz Carlos
Addition? How? Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
Jerry Avins <jya@ieee.org> wrote in message news:
> > Addition? How? > > Jerry
If you linearize the G711 you get 13 bit samples and then you need a 13 bit adder. If you add the mantissas, shifting them by the exponents and discarding the bits that fall out the representation, you need a 6 bit adder. Of course this a better aproach if you are doing it in hardware (FPGA stuff), but I think that you can save some clock cycles of the DSP/MPU if you do not do a complete expansion of the samples to add them. Luiz Carlos.