I'm new to to DSP in general and have been trying my hand at making some very simple VST's just for practice purposes.

I am trying to convert the stereo channels into Mid (in the left channel) and Side (in the right) without using a placeholder to store output. Here is a very basic version of the code I am currently trying:

    *LeftSample = (*LeftSample + *RightSample) * 0.5;
    *RightSample = (((*LeftSample * 2) - *RightSample) - *RightSample) * 0.5;

The first line assigns the mid output to the left channel, but in the second line I am trying to reverse the mid conversion so that I can use the left channel's original output when performing the L-R operation to create the side channel in the right output.

Am I missing something in thinking that this should be achievable? Is there some reason that

    (*LeftSample * 2) - *RightSample

does not reverse the mid conversion, (L+R) * 0.5? Is it not possible to derive the original left channel using the mid signal and the right signal?

Again, I'm new to this, so I apologize for any errors in terminology I have made, and for anything that has been poorly communicated. I appreciate all feedback and criticism (please, tear any errors I've made to pieces). I've looked around quite a bit, and haven't had any luck; if anyone has any resources or directions to point me in, I would greatly, greatly appreciate it!


You can fully reconstruct L and R from M and S, as you suspect. In your case:

$ M = {{L + R} \over 2} $

$ L = 2M - R $

$ S = {{L - R} \over 2} $


$ S = {{2M - R - R} \over 2} $.

So the math checks out. Are you not getting the results you expect?

When I've worked with M&S in the past, I've alyways just done the scaling by 1/2 when returning to L&R. I guess it depends on what you're intending on doing with the M&S signals though. If you want the sum of M and S to have equal energy to the sum of L and R, you should scale by $ 1 \over \sqrt 2 $ when converting both to and from M&S.

  • $\begingroup$ Thank you! The normalization was what was tripping me up. I'm using duplicate tracks and phase inversion to test it out, and although the results were close in my original attempt, I couldn't quite figure out why the phase cancellation wasn't occurring. $\endgroup$
    – cjaybo
    Oct 16 '15 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.