I just watched this great tutorial named "The Magic Of Mid Side" by Dan Worrall ( if you don't know Dan, you should SUBSCRIBE to him and "press the bell" to get all notifications as his content is really incredible ), and I thought it would be an excellent exercise to recreate the ENCODER / DECODER for M/S using Max4Live.
As Dan outlined in the video, the ENCODER and DECODER algorithm is pretty much the same... The only detail is that when ENCODING, you probably will want to divide the signal by 2 ( aka multiply it by 0.5 ) for that reason I have created two devices: ENCODER, starts with 0.5 multiplication of the signal DECODER, starts with 1.0 multiplication ( won't change the gain ) of the signal.
For a more feature-rich solution, you probably should use Voxengo MSED instead which will not only ENCODE / DECODE to/from M/S but also give you a super polished UI.
Have stereo fun!
As explained by Dan in his video:
- to encode to MID we will sum L and R
- to encode to SIDE we will subtract R from L
This will likely clip your MID channel, in order to avoid clipping we will half the gain before encoding
mid = ( L + R ) * 0.5
sid = ( L - R ) * 0.5
To decode the signal we will reverse what we have done in the ENCODER
L = mid + sid
R = mid - sid
L = L + R + ( L - R )
R = L - R - ( L - R )
Dan explains really well why you would want to do that on his video, check it out and don't forget to subscribe to Dan's channel!