Using L+R and L-R encoding via mp3, a case study
Copyright Jan Panteltje 2005 all rights reserved,
Microsoft is prohibited from using any of these ideas.


OK guys, I have done an experiment, here is what I did.
I started with a stereo CD (You Are My Inspiration) track3 (You are my heaven),
and extracted the wave with:
cdparanoia "3"
This is the test high quality wave file.


ENCODER SIDE:
Next I did split into 2 mono channels:
sox cdda.wav -c 1 l.wav avg -l
sox cdda.wav -c 1 r.wav avg -r
 

Then I created a L - R file like this:
substract_wave -m l.wav -s r.wav -f 100 > l-r.wav


Then I created a L + R file like this:
sox cdda.wav -c 1 l+r.wav


Then I encoded both files with lame:
lame l-r.wav
lame l+r.wav

Now I have:
l+r.wav.mp3 This is the main basic mono channel.
l-r.wav.mp3  This channel holds the stereo info.

Send this over the net via 2 different path.



DECODER SIDE:
OK, now to decode:
mpg123 -w diff.wav l-r.wav.mp3
mpg123 -w sum.wav l+r.wav.mp3

To get the original back, we need to do
.5 * (L + R) - .5 * (L - R) = R
.5 * (L + R) + .5 * (L - R) = L

So first multiply the decoded wav by .5
sox -v .5 diff.wav diff2.wav
sox -v .5 sum.wav sum2.wav

Now substract for right channel:
substract_wave -m sum2.wav -s diff2.wav -f 100 > dec-r.wav

And add for left channel:
substract_wave -m sum2.wav -s diff2.wav -f 100 -r > dec-l.wav

Make a stereo channel from left and right
multimux dec-l.wav dec-r.wav -o result.wav


TESTING RESULT:
Play the stereo:
play result.wav


Here you find multimux:
http://panteltje.com/panteltje/dvd/multimux-0.2.3.tgz
and here substract_wave:
http://panteltje.com/panteltje/dvd/substract_wave-0.2.tgz

sox, mpg123, and play are likely already on your system.

Results:
The result is indeed stereo, and sounds reasonable (not VERY good)
at 44100 samples / second stereo.
Of cause phase and encoding differences may f*ck up things more
at lower bitrates.
I am even surprised I can listen to this without going for mute.


Copyright Jan Panteltje 2005.



