A stereo audio file with containing only signal in one channel will result in a LRC file with signal in all three channels.
I am referring to these lines of code:
Code: Select all
MidSideDecoder::run (shared_ptr<const AudioBuffers> in, int channels)
{
int const N = min (channels, 3);
auto out = make_shared<AudioBuffers>(channels, in->frames ());
for (int i = 0; i < in->frames(); ++i) {
auto const left = in->data()[0][i];
auto const right = in->data()[1][i];
auto const mid = (left + right) / 2;
if (N > 0) {
out->data()[0][i] = left - mid;
}
if (N > 1) {
out->data()[1][i] = right - mid;
}
if (N > 2) {
out->data()[2][i] = mid;
}
}
Say if we have signal in only Lin (Rin=0), then
Cout = (Lin+0)/2 = Lin/2
and
Lout = Lin-Cout = Lin-Lin/2 = Lin/2
and
Rout = Rin-Cout = 0-Lin/2 = -Lin/2
That means that when signal is only present in the left channel of the stereo file, after mid-side decoding it will be played in all three channels at half amplitude, but in contra-phase in the right channel. I guess that some of the mixing then actually takes place in front of the speakers in the auditorium when Rout cancels out Cout?
Anyone that can point me to where the math origins?
I would have expected something along with:
Cout = (Lin+Rin)/2
S = (Lin-Rin)/2
Lout = (Cout+S)/2 = ((Lin+Rin)/2+(Lin-Rin)/2)/2 = Lin/2
Rout = (Cout-S)/2 = ((Lin+Rin)/2-(Lin-Rin)/2)/2 = Rin/2
Thanks,
Christian