DSPRelated.com
Forums

Merging G.711 files

Started by Andrew Chalk December 11, 2006
I plan to play them. Thanks for the quick-and-dirty method -- I'll try it.

- A

"Phil Frisbie, Jr." <phil@hawksoft.com> wrote in message 
news:457e47f7$0$80062$742ec2ed@news.sonic.net...
> Andrew Chalk wrote: > >> I have two G.711 files/streams and I want to merge them. > > What are you going to do with them after you merge them? > >> They represent each side of a telephone conversation. I know I can create >> a 'stereo' .wav file but I would rather create a single channel (mono) >> file. Can I just add together each contemporaneous data point? > > No, because G.711 is a logarithmic value, similar to an 8-bit float value. > If you add them it will be like you are multiplying them! So, as has > already been said, the proper way to add the streams would be to decode > them to 16 bit PCM, add them, and reconvert them to G.711. > > Now, if you are looking for a short-cut, and the stream is just going to > be sent to a speaker, then you can simply take to 'odd' samples from one > stream and interleave them with the 'even' samples of the other stream. I > have seen (heard) this technique used with 3 or 4 streams with good > results. > > -- > Phil Frisbie, Jr. > Hawk Software > http://www.hawksoft.com
What about a slight variation: If the value about to be added is 'zero 
amplitude' use the sample from the other stream instead?


"Chetan Vinchhi" <vinchhi@gmail.com> wrote in message 
news:1165904758.266512.111940@73g2000cwn.googlegroups.com...
> On Dec 12, 11:10 am, "Phil Frisbie, Jr." <p...@hawksoft.com> wrote: >> >> Now, if you are looking for a short-cut, and the stream is just going to >> be sent to a speaker, then you can simply take to 'odd' samples from one >> stream and interleave them with the 'even' samples of the other stream. >> I have seen (heard) this technique used with 3 or 4 streams with good >> results. > > For 2 streams, this sounds like a rough equivalent of downsampling by a > factor of 2 and adding. Wouldn't it give rise to strange artifacts if > there is significant enery in high frequencies (e.g. for some female > voices)? > > C >
Tried the short cut. Yuk! Massive degradation in voice quality!

- A
"Phil Frisbie, Jr." <phil@hawksoft.com> wrote in message 
news:457e47f7$0$80062$742ec2ed@news.sonic.net...
> Andrew Chalk wrote: > >> I have two G.711 files/streams and I want to merge them. > > What are you going to do with them after you merge them? > >> They represent each side of a telephone conversation. I know I can create >> a 'stereo' .wav file but I would rather create a single channel (mono) >> file. Can I just add together each contemporaneous data point? > > No, because G.711 is a logarithmic value, similar to an 8-bit float value. > If you add them it will be like you are multiplying them! So, as has > already been said, the proper way to add the streams would be to decode > them to 16 bit PCM, add them, and reconvert them to G.711. > > Now, if you are looking for a short-cut, and the stream is just going to > be sent to a speaker, then you can simply take to 'odd' samples from one > stream and interleave them with the 'even' samples of the other stream. I > have seen (heard) this technique used with 3 or 4 streams with good > results. > > -- > Phil Frisbie, Jr. > Hawk Software > http://www.hawksoft.com
"Andrew Chalk" <achalk@magnacartasoftware.com> writes:

> Tried the short cut. Yuk! Massive degradation in voice quality!
Andrew, Could it be that difficult to simply create a 256-byte mapping array and convert the data to linear PCM? I suppose you'd have to maintain two arrays, one for u-law and one for A-law, and use the appropriate one depending on the stream. I think I could've done this in the time it's taken to post and repost these several replies. This paper (which I found in about 3 seconds) has the mapping and inverse mapping information http://www.cs.wfu.edu/~burg/nsf-due-0340969/worksheets/NonlinearCompanding.pdf --RY -- % Randy Yates % "...the answer lies within your soul %% Fuquay-Varina, NC % 'cause no one knows which side %%% 919-577-9882 % the coin will fall." %%%% <yates@ieee.org> % 'Big Wheels', *Out of the Blue*, ELO http://home.earthlink.net/~yatescr
Andrew Chalk wrote:
> What about a slight variation: If the value about to be added is 'zero > amplitude' use the sample from the other stream instead?
Do you want to treat one stream as primary and mix in samples from the other stream whenever the primary stream is zero? Chances are, you will hear the primary stream only with occassional distortions (probably clicks). Getting a zero-valued sample is rare unless you are playing digital silence. When you do have a zero, a sample from the other stream may look and behave like a discontinuity. Can you tell us exactly what you are trying to achieve and what your constraints are? C
Not if I had the mapping. Thanks for the reference.

- A
"Randy Yates" <yates@ieee.org> wrote in message 
news:m3mz5s8lb3.fsf@ieee.org...
> "Andrew Chalk" <achalk@magnacartasoftware.com> writes: > >> Tried the short cut. Yuk! Massive degradation in voice quality! > > Andrew, > > Could it be that difficult to simply create a 256-byte mapping array > and convert the data to linear PCM? I suppose you'd have to maintain > two arrays, one for u-law and one for A-law, and use the appropriate > one depending on the stream. > > I think I could've done this in the time it's taken to post and repost > these several replies. This paper (which I found in about 3 seconds) > has the mapping and inverse mapping information > > > http://www.cs.wfu.edu/~burg/nsf-due-0340969/worksheets/NonlinearCompanding.pdf > > --RY > > -- > % Randy Yates % "...the answer lies within your soul > %% Fuquay-Varina, NC % 'cause no one knows which side > %%% 919-577-9882 % the coin will fall." > %%%% <yates@ieee.org> % 'Big Wheels', *Out of the Blue*, ELO > http://home.earthlink.net/~yatescr
Each file is one side of a telephone conversation (8kHz muLaw). I am trying 
to merge them into one, mono, file.

- A

"Chetan Vinchhi" <vinchhi@gmail.com> wrote in message 
news:1165998705.733453.10090@80g2000cwy.googlegroups.com...
> > Andrew Chalk wrote: >> What about a slight variation: If the value about to be added is 'zero >> amplitude' use the sample from the other stream instead? > > Do you want to treat one stream as primary and mix in samples from the > other stream whenever the primary stream is zero? Chances are, you will > hear the primary stream only with occassional distortions (probably > clicks). Getting a zero-valued sample is rare unless you are playing > digital silence. When you do have a zero, a sample from the other > stream may look and behave like a discontinuity. > > Can you tell us exactly what you are trying to achieve and what your > constraints are? > > C >
Andrew Chalk wrote:
> Each file is one side of a telephone conversation (8kHz muLaw). I am trying > to merge them into one, mono, file.
The sum solution would probably be most suitable in this case. If you want a simpler scheme, use the trivial voting algorithm - pick the larger of the two values. You can do this in the mu-law domain. This is a refinement of your replace-if-zero scheme. I think it may work well except for regions where both parties are talking or if there is a lot of background noise. C