# Converting Stereo to Mono taking into account Phase modulation

Started by December 16, 2008
```Hi,

I am trying to convert stereo into mono in the following manner:
R/2 + L/2
This works at most of the times, however, on some case the phase of
the right channel is about 180deg of the left channel, using the above
formula with phase shift of 180deg results a mute output, the easiest
way to resolve that is to use R/2 - L/2 and not R/2 + L/2, this
however, is not enough as the phase is not fixed at 180deg.

Taking the above in mind, I wonder what is the best way to convert
stereo into mono taking in to account phase shifts.

Thanks,
```
```Nada wrote:
> Hi,
>
> I am trying to convert stereo into mono in the following manner:
> R/2 + L/2
> This works at most of the times, however, on some case the phase of
> the right channel is about 180deg of the left channel, using the above
> formula with phase shift of 180deg results a mute output, the easiest
> way to resolve that is to use R/2 - L/2 and not R/2 + L/2, this
> however, is not enough as the phase is not fixed at 180deg.
>
> Taking the above in mind, I wonder what is the best way to convert
> stereo into mono taking in to account phase shifts.

What is the origin of the stereo signal? If the left and right
microphones have signals of about equal amplitude and opposite phase,
then a third microphone halfway between them would indeed record little
or no sound. (L+R)/2 simulates the middle microphone. If this is a real
problem, no sound id the correct result. If it is merely academic, then

Jerry
--
Engineering is the art of making what you want from things you can get.
&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;
```
```On Dec 16, 2:37&#2013266080;pm, Jerry Avins <j...@ieee.org> wrote:
> > Hi,
>
> > I am trying to convert stereo into mono in the following manner:
> > R/2 + L/2
> > This works at most of the times, however, on some case the phase of
> > the right channel is about 180deg of the left channel, using the above
> > formula with phase shift of 180deg results a mute output, the easiest
> > way to resolve that is to use R/2 - L/2 and not R/2 + L/2, this
> > however, is not enough as the phase is not fixed at 180deg.
>
> > Taking the above in mind, I wonder what is the best way to convert
> > stereo into mono taking in to account phase shifts.

first, do you really mean PHASE SHIFT or do you mean POLARITY or do
you mean TIME DELAY.

These three things are RELATED  but they are not the same things.

Reversing wires or passing through an inverter creates a polarity
shift.  Mis aligned tape heads cause TIME DELAY shift.   What is

Mark

```
```On Dec 17, 2:02&#2013266080;am, makol...@yahoo.com wrote:
> On Dec 16, 2:37&#2013266080;pm, Jerry Avins <j...@ieee.org> wrote:
>
> > > Hi,
>
> > > I am trying to convert stereo into mono in the following manner:
> > > R/2 + L/2
> > > This works at most of the times, however, on some case the phase of
> > > the right channel is about 180deg of the left channel, using the above
> > > formula with phase shift of 180deg results a mute output, the easiest
> > > way to resolve that is to use R/2 - L/2 and not R/2 + L/2, this
> > > however, is not enough as the phase is not fixed at 180deg.
>
> > > Taking the above in mind, I wonder what is the best way to convert
> > > stereo into mono taking in to account phase shifts.
>
> first, do you really mean PHASE SHIFT or do you mean POLARITY or do
> you mean TIME DELAY.
>
> These three things are RELATED &#2013266080;but they are not the same things.
>
> Reversing wires or passing through an inverter creates a polarity
> shift. &#2013266080;Mis aligned tape heads cause TIME DELAY shift. &#2013266080; What is
> causing your "PHASE SHIFT" ?
>
> Mark

Thanks for the quick response, the source of the signal is an
arbitrary compressed audio stream ( ASF File, live feed taken from the
internet, MP3, WMA, ... ) on certain scenarios I get (Left + Right) /
2 ~= 0, I am looking for a stereo to mono algorithm which is apathetic
to 'phase distortions'.
```
```On Dec 17, 7:52&#2013266080;am, Nadav <nadav...@gmail.com> wrote:
> On Dec 17, 2:02&#2013266080;am, makol...@yahoo.com wrote:
>
>
>
>
>
> > On Dec 16, 2:37&#2013266080;pm, Jerry Avins <j...@ieee.org> wrote:
>
> > > > Hi,
>
> > > > I am trying to convert stereo into mono in the following manner:
> > > > R/2 + L/2
> > > > This works at most of the times, however, on some case the phase of
> > > > the right channel is about 180deg of the left channel, using the above
> > > > formula with phase shift of 180deg results a mute output, the easiest
> > > > way to resolve that is to use R/2 - L/2 and not R/2 + L/2, this
> > > > however, is not enough as the phase is not fixed at 180deg.
>
> > > > Taking the above in mind, I wonder what is the best way to convert
> > > > stereo into mono taking in to account phase shifts.
>
> > first, do you really mean PHASE SHIFT or do you mean POLARITY or do
> > you mean TIME DELAY.
>
> > These three things are RELATED &#2013266080;but they are not the same things.
>
> > Reversing wires or passing through an inverter creates a polarity
> > shift. &#2013266080;Mis aligned tape heads cause TIME DELAY shift. &#2013266080; What is
> > causing your "PHASE SHIFT" ?
>
> > Mark
>
> Thanks for the quick response, the source of the signal is an
> arbitrary compressed audio stream ( ASF File, live feed taken from the
> internet, MP3, WMA, ... ) on certain scenarios I get (Left + Right) /
> 2 ~= 0, I am looking for a stereo to mono algorithm which is apathetic
> to 'phase distortions'.- Hide quoted text -
>
> - Show quoted text -

that is probably a polarity issue and the best bet is to try both
polarities and pick the one with the greater output.

Mark
```
```On Tue, 16 Dec 2008 14:37:08 -0500, Jerry Avins <jya@ieee.org> wrote:
>> I am trying to convert stereo into mono in the following manner:
>> R/2 + L/2
>> This works at most of the times, however, on some case the phase of
>> the right channel is about 180deg of the left channel, using the above
>> formula with phase shift of 180deg results a mute output, the easiest
>> way to resolve that is to use R/2 - L/2 and not R/2 + L/2, this
>> however, is not enough as the phase is not fixed at 180deg.
>>
>> Taking the above in mind, I wonder what is the best way to convert
>> stereo into mono taking in to account phase shifts.

> What is the origin of the stereo signal? If the left and right
> microphones have signals of about equal amplitude and opposite phase,
> then a third microphone halfway between them would indeed record little
> or no sound. (L+R)/2 simulates the middle microphone. If this is a real
> problem, no sound id the correct result. If it is merely academic, then
> any answer you like is "right", so do what you please.

Jerry,

I know of at least two possible interpretations of "convert stereo
into mono":

1) Add two audio signals that happened to be stored/recorded in a
two-channel format. This is the mathematical (L+R)/2 approach.

2) Convert an existing tape, vinyl disk, or CD recording so it
can be played back through a single speaker but still sounds
"as much like the original as possible".

It sounds like Nada is trying to accomplish the latter, and seeing
the same poor results as I had years back when I wired two RCA
plugs together. <grin!>

I would think that using something like:

output = max(L,R)

would sound better than

output=((L+R)/2)

for the reasons Nada already mentioned. Is anyone aware of a "better"
way to combine the L and R signals (e.g. a more pleasant and/or
more faithful-to-the-original reproduction)?

Frank McKenney
--
"We are stuck with 'technology' when what we really want is just
stuff that works. How do you recognize something that is still
'technology'? A good clue is if it comes with a manual."
-- Douglas Adams / The Salmon of Doubt
--
Frank McKenney, McKenney Associates
Richmond, Virginia / (804) 320-4887
Munged E-mail: frank uscore mckenney ayut mined spring dawt cahm (y'all)
```
```Frnak McKenney wrote:
..
> I know of at least two possible interpretations of "convert stereo
> into mono":
>
>  1) Add two audio signals that happened to be stored/recorded in a
>     two-channel format. This is the mathematical (L+R)/2 approach.
>
>  2) Convert an existing tape, vinyl disk, or CD recording so it
>     can be played back through a single speaker but still sounds
>     "as much like the original as possible".
>
> It sounds like Nada is trying to accomplish the latter, and seeing
> the same poor results as I had years back when I wired two RCA
> plugs together. <grin!>
>
> I would think that using something like:
>
>   output = max(L,R)
>
> would sound better than
>
>   output=((L+R)/2)
>

No, the only proper way to sum channels (which is all that a stereo to
mono conversion is) is to, well, sum them (and rescale).  The problem is
that it is a well-known hack to impart a sort-of-stereo quality to a
mono source  by duplicating it and inverting one channel. It is one of a
number of processes that are by definition "mono-incompatible". If one
obtains such a source, scope for mono conversion is clearly somewhat
limited, and the best solution will likely be to accept it is really
mono and just use one channel.

My understanding of the OP was that some files were OK, and some others
exhibited the inversion throughout.  If the effect is time-varying
within one file, that is a somewhat different, and strange, situation,
which would have to be dealt with in some ad-hoc per-file  way.

The problem with the max(L,R) approach is that it is similar to what a
dynamics compressor/expander/ducker does (where one channel is a
"side-chain" relative to the other); artifacts such as "breathing" or
"pumping" will likely appear, such that the output will be far from
clean compared to the original.

Richard Dobson
```
```Frnak McKenney <frnak@far.from.the.madding.crowd.com> wrote:

> I know of at least two possible interpretations of "convert stereo
> into mono":

> 1) Add two audio signals that happened to be stored/recorded in a
>    two-channel format. This is the mathematical (L+R)/2 approach.

> 2) Convert an existing tape, vinyl disk, or CD recording so it
>    can be played back through a single speaker but still sounds
>    "as much like the original as possible".

(snip)
> I would think that using something like:

>  output = max(L,R)

> would sound better than

I would expect it to sound worse, but then again I haven't
tried it.

Consider L=sin(wt)  R=cos(wt), and look at max(L,R).

The fundamental is at 2*w, and with the sharp corners
it will have harmonics going up from there.  To me that
will sound very different from sin or cos.

-- glen
```
```On Wed, 17 Dec 2008 16:14:28 +0000, Richard Dobson <richarddobson@blueyonder.co.uk> wrote:
> Frnak McKenney wrote:
> ..
>> I know of at least two possible interpretations of "convert stereo
>> into mono":
>>
>>  1) Add two audio signals that happened to be stored/recorded in a
>>     two-channel format. This is the mathematical (L+R)/2 approach.
>>
>>  2) Convert an existing tape, vinyl disk, or CD recording so it
>>     can be played back through a single speaker but still sounds
>>     "as much like the original as possible".
>>
>> It sounds like Nada is trying to accomplish the latter, and seeing
>> the same poor results as I had years back when I wired two RCA
>> plugs together. <grin!>
>>
>> I would think that using something like:
>>
>>   output = max(L,R)
>>
>> would sound better than
>>
>>   output=((L+R)/2)
>
> No, the only proper way to sum channels (which is all that a stereo to
> mono conversion is) is to, well, sum them (and rescale).  The problem is
> that it is a well-known hack to impart a sort-of-stereo quality to a
> mono source  by duplicating it and inverting one channel. It is one of a
> number of processes that are by definition "mono-incompatible". If one
> obtains such a source, scope for mono conversion is clearly somewhat
> limited, and the best solution will likely be to accept it is really
> mono and just use one channel.

Ah. Back in per-history, when black vinyl was the media-du-jour for
recordings, I recall some of my (large-print STEREO) LPs having a very-
small-print note saying that they had been created from (small print
mono) originals. Now I know how it was done. <grin!>  Thanks for the
information.

And you suspect that the "problem files" the OP has were created
using this process. Okay.

> My understanding of the OP was that some files were OK, and some others
> exhibited the inversion throughout.  If the effect is time-varying
> within one file, that is a somewhat different, and strange, situation,
> which would have to be dealt with in some ad-hoc per-file  way.

The OP's phrasing was:

This works at most of the times, however, on some case the phase
of the right channel is about 180deg of the left channel, ...

which I interpreted as "intermittent within one file". Thanks for
offering an alternative reading, which sounds more likely to be
the actual case than mine.

Would the OP care to clarify?

> The problem with the max(L,R) approach is that it is similar to what a
> dynamics compressor/expander/ducker does (where one channel is a
> "side-chain" relative to the other); artifacts such as "breathing" or
> "pumping" will likely appear, such that the output will be far from
> clean compared to the original.

If I start out with the same L=reverse(R) signal assumption, I can
see all sorts of difficulties. On the other hand, if, as you say,
one knows how the signal was created, using L _or_ R alone would
provide the best "mono interpretation".

Aha! I see a fortune to be made making stereo-to-mono RCA adapters
with a switch so you can choose L, R, or L+R! (And, with a good
marketing department, we can even sell them to people owning 7"(?)
45RPM disks but playing them on a stereo turntable. <grin!>)

Frank McKenney
--
A lesson to be learned from this puzzle is that it is not
necessarily the pieces which seem to fit satisfactorily that
decide whether or not the picture to date is correct, it is
the pieces which don't fit that really decide the issue.
-- Peter Warlow, English physicist
--
Frank McKenney, McKenney Associates
Richmond, Virginia / (804) 320-4887
Munged E-mail: frank uscore mckenney ayut mined spring dawt cahm (y'all)
```
```On Wed, 17 Dec 2008 19:40:19 +0000 (UTC), glen herrmannsfeldt <gah@ugcs.caltech.edu> wrote:
>
>> I know of at least two possible interpretations of "convert stereo
>> into mono":
>
>> 1) Add two audio signals that happened to be stored/recorded in a
>>    two-channel format. This is the mathematical (L+R)/2 approach.
>
>> 2) Convert an existing tape, vinyl disk, or CD recording so it
>>    can be played back through a single speaker but still sounds
>>    "as much like the original as possible".
>
> (snip)
>> I would think that using something like:
>
>>  output = max(L,R)
>
>> would sound better than
>
> I would expect it to sound worse, but then again I haven't
> tried it.
>
> Consider L=sin(wt)  R=cos(wt), and look at max(L,R).
>
> The fundamental is at 2*w, and with the sharp corners
> it will have harmonics going up from there.  To me that
> will sound very different from sin or cos.

Glen,

Thanks to Richard's comments I can see why using max(L,R) on a
signal where L=reverse(R) could have some displeasing effects.
Are you assuming this for the above? Or are you saying that
two only-mildly-related channels would have problems if you
combined them with max(L,R)?

(It's probably not critical to the OP at this point. I'm just
curious and having trouble picturing the effect with two
complex... er, "complicated" waveforms (sorry -- forgot for a
moment where I was <grin!>).

Frank
--
It is with theories as with wells: you may see to the bottom of
the deepest if there be any water there, while another shall pass
for wondrous profound when 'tis merely shallow, dark, and empty.
-- Jonathan Swift
--
Frank McKenney, McKenney Associates
Richmond, Virginia / (804) 320-4887
Munged E-mail: frank uscore mckenney ayut mined spring dawt cahm (y'all)
```