Understanding the inner workings of the Mid-side decoder...

Anything and everything to do with DCP-o-matic.
Post Reply
chr.hove
Posts: 7
Joined: Tue Nov 15, 2016 4:03 pm

Understanding the inner workings of the Mid-side decoder...

Post by chr.hove »

The mid-side decoder (DCP->Audio->Processor) really puzzles me.
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;
		}
	}
I understand the calculation of the center channel: Cout=(Lin+Rin)/2, but the Lout and Rout not so much.
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
carl
Site Admin
Posts: 2232
Joined: Thu Nov 14, 2013 2:53 pm

Re: Understanding the inner workings of the Mid-side decoder...

Post by carl »

Hey Christian,

This is a very interesting question, and you make a good point about what the code is doing.

Strangely enough, the answer is: I don't remember. This code was added nearly 10 years ago, and I didn't document the thoughts behind it. My best guess is that I was trying to make an unsophisticated decoder for some Dolby encoding. It's strange to have a project so old that you forget things like this.

I don't know what the best way forward is. Nowadays I'm less convinced that these filters make so much sense. Certainly I think any filters that DoM does have should be fairly "safe bets" i.e. unlikely to make things any worse.
Carsten
Posts: 2580
Joined: Tue Apr 15, 2014 9:11 pm
Location: Germany

Re: Understanding the inner workings of the Mid-side decoder...

Post by Carsten »

I noticed this phase-reverse between L and R a while ago while I was testing some M/S DCPs on our sound system.

I think I brought it up on the forum or on Mantis then, but somehow lost it soon after, because it was in a thread about a different topic.

I think it's a good idea to have a Mid/Side-Decoder in DCP-o-matic, since so many source files are stereo.

Maybe Carl can fix this and create a test version.


edit: I found it, it wasn't on this forum...

http://www.film-tech.com/vbb/forum/main ... ound/page3
Last edited by Carsten on Tue Nov 21, 2023 2:23 pm, edited 1 time in total.
Antti N
Posts: 19
Joined: Mon Nov 16, 2020 5:03 pm

Re: Understanding the inner workings of the Mid-side decoder...

Post by Antti N »

Some kind of a "pseudo Pro Logic" or even just a basic and safe mid/side decoder would be much appreciated in future versions, too.

It's actually getting more – not less – useful for me nowadays. A lot of older audio processors with Pro Logic / matrix decoding for 2.0 DCP audio (such as Dolby DMA8+ and CP750) are being retired, and current solutions such as CP950 and the IMS3000's built-in audio processor don't have this capability.

In a couple of months, I'm doing a big short film festival with heaps of 2.0 content. For years, we've simply been doing Pro Logic decoding in the booth with great results, but since that won't be an option any longer…

Carl: if you can find the time to look into the phase shifting issue, I'd be happy to try out any test versions and report my results!
chr.hove
Posts: 7
Joined: Tue Nov 15, 2016 4:03 pm

Re: Understanding the inner workings of the Mid-side decoder...

Post by chr.hove »

Carl:
Thanks for the explanation.
As Antti N I encounter 2.0 material on a regular basis (both new short films and old material) and would love a way to do 2.0 -> 3.0 in a safe and reliable way, preferably following some proven industry standard.
Post Reply