Stereo expander algorithm?

DSP, Plug-in and Host development discussion.
jdtrbn
KVRist
226 posts since 29 Oct, 2005 from Espoo, Finland

Post Wed Apr 09, 2008 2:06 am

Hi!

How do stereo expanders work? I was thinking about this and I could not find a trivial answer. How to find what data in right and left channels are more characteristic to one channel than another? Do you need a fourier transform? On the other hand, a stereo->mono converter can be untrivial because a small phase difference can distort the frequency spectrum if a simple addition is used.

I'm indeed quite new to this. I tried Google but couldn't find info. If I have missed some source that explains this kind of things, please point me to the right direction. :)

Thanks!

duncanparsons
KVRAF
8379 posts since 11 Apr, 2003 from now on the flat

Post Wed Apr 09, 2008 2:13 am

chack www.musicdsp.org there are a couple there, some even added recently. A common trick is to delay one channel by a couple of samples, but watch for different samplerates having different effects.

You could employ a few different techniques, such as different freqs expanding by different amounts...

DSP
Image

iGoA
KVRist
56 posts since 20 Sep, 2006 from Hamburg, Germany

Post Wed Apr 09, 2008 4:39 am

Maybe this thread helps:
http://www.kvraudio.com/forum/viewtopic ... ght=stereo

Especially this algorithm could be exactly, what you want:

Code: Select all

M = (L+R)/sqrt(2);   // obtain mid-signal from left and right
S = (L-R)/sqrt(2);   // obtain side-signal from left and right

// amplify mid and side signal seperately:
M *= 2*(1-width);
S *= 2*width;

L = (M+S)/sqrt(2);   // obtain left signal from mid and side
R = (M-S)/sqrt(2);   // obtain right signal from mid and side


User avatar
Music Engineer
KVRAF
3828 posts since 8 Mar, 2004 from Berlin, Germany

Post Wed Apr 09, 2008 5:23 am

aha, that's my pseudocode. by now, i've also written a small article on that topic:

http://www.rs-met.com/documents/tutoria ... essing.pdf
Image

User avatar
Kingston
KVRAF
6476 posts since 16 Dec, 2002

Post Wed Apr 09, 2008 5:58 am

iGoA wrote:Maybe this thread helps:
http://www.kvraudio.com/forum/viewtopic ... ght=stereo

Especially this algorithm could be exactly, what you want:

Code: Select all

M = (L+R)/sqrt(2);   // obtain mid-signal from left and right
S = (L-R)/sqrt(2);   // obtain side-signal from left and right

// amplify mid and side signal seperately:
M *= 2*(1-width);
S *= 2*width;

L = (M+S)/sqrt(2);   // obtain left signal from mid and side
R = (M-S)/sqrt(2);   // obtain right signal from mid and side

That's hardly an algorithm. It's a bog standard mid-side summing matrix (hardly a matrix either). The sqrt() will probably confuse many but it does nothing but weight the mixing relationship (and it's terribly unnecessary for optimal code).

For actual stereo expansion/enhancement I would look at haas, and other delay and filter based solutions.
jdtrbn wrote:I tried Google but couldn't find info.
actually, there is a great wealth of stereo expansion to be found on google. just not by the most obvious keywords and sources.

I once hit a motherload and stumbled on several modern stereo-to-surround re-panning algos.

White papers and all. Still haven't seen some of them as plugins, probably due to patent restrictions.

User avatar
Music Engineer
KVRAF
3828 posts since 8 Mar, 2004 from Berlin, Germany

Post Wed Apr 09, 2008 6:12 am

Kingston wrote:The sqrt() will probably confuse many but it does nothing but weight the mixing relationship (and it's terribly unnecessary for optimal code).
granted. i think, i pointed that out in the old thread myself (and we babbled quite some bit about its purpose there). but it's a good idea to mention it here again.
Image

mystran
KVRAF
5384 posts since 12 Feb, 2006 from Helsinki, Finland

Post Wed Apr 09, 2008 7:01 am

Kingston wrote:
That's hardly an algorithm. It's a bog standard mid-side summing matrix (hardly a matrix either). The sqrt() will probably confuse many but it does nothing but weight the mixing relationship (and it's terribly unnecessary for optimal code).
Actually, by replacing the:

Code: Select all

  foo / sqrt(2.0);
with

Code: Select all

  foo * (1.0/sqrt(2.0));
most compilers will be clever enough to realize that (1.0/sqrt(2.0)) is a constant, and you'll get rid of the division and the square root.

Really good compilers (haven't done an extensive check) will naturally do the above optimization automatically, but it might be worth trying whether there's a speed difference between the two.

ddummer
KVRian
830 posts since 13 Jul, 2002

Post Wed Apr 09, 2008 7:12 am

Or simply pre-calculate the result of sqrt(2):

http://www.math.com/students/calculator ... e-root.htm

//Daniel :)

User avatar
Kingston
KVRAF
6476 posts since 16 Dec, 2002

Post Wed Apr 09, 2008 7:38 am

Surround sound production is basically the only field that still spends considerable funds on researching stereo enhancement - or more generally - spatial enhancement.

This here is my all-time favourite:

http://www.irisa.fr/prive/kadi/Sujets_C ... endano.pdf

I actually used that as a starting point for my graduation dissertation. highly recommended. It contains plenty of references and keywords for everything one needs to know.

AFAIK, stuff like that is only featured on super expensive post-production surround processors this far.

can be easily (and cheaply) adapted to stereo processing of course.

jdtrbn
KVRist
226 posts since 29 Oct, 2005 from Espoo, Finland

Post Wed Apr 09, 2008 10:38 am

You're such a great help, guys!

I'm still a bit curious about stereoizing. I remember doing this with small delays in my old tracking(.module) days, but now this seems to be easily associated with reverbs, which can damage the clarity of sounds, I'm afraid. I think Cubase comes with a useful plug-in but this doesn't seem to be a popular subject in freeware VSTs.

jeremyedmonds
KVRer
1 posts since 7 Aug, 2016

Re:

Post Sat Aug 06, 2016 5:06 pm

AUTO-ADMIN: Non-MP3, WAV, OGG, SoundCloud, YouTube, Vimeo, Twitter and Facebook links in this post have been protected automatically. Once the member reaches 5 posts the links will function as normal.
iGoA wrote:

Code: Select all (#)

M = (L+R)/sqrt(2);   // obtain mid-signal from left and right
S = (L-R)/sqrt(2);   // obtain side-signal from left and right

// amplify mid and side signal seperately:
M *= 2*(1-width);
S *= 2*width;

L = (M+S)/sqrt(2);   // obtain left signal from mid and side
R = (M-S)/sqrt(2);   // obtain right signal from mid and side

I know that this is a very old thread but I felt like I should respond, as I think I see a problem here. Maybe my algebra is wrong, but it looks like the square root falls out altogether. I think it could be simplified to this:

Code: Select all (#)

// Should be the same result as the above code! (Please check to make sure)
L = L+R-2*R*width;
R = L+R-2*L*width;
I think it really is this simple. In fact, the multiplication by two is unnecessary, as "width" is a multiplier. If it were zero, you would get the sum of the left and right channels. If it is getting larger, you are just subtracting a portion of the other channel, which leaves more of the audio components that are unique to that channel. If this is all that it's doing, you might as well use something like this...

Code: Select all (#)

// All this does is subtract out some of the other channel, accentuating the difference between them
L=L-R*width;
R=R-L*width;

200gaga
KVRer
1 posts since 21 Nov, 2012

Re: Stereo expander algorithm?

Post Fri Oct 11, 2019 4:05 am

Hi, given the original algorithm, it the width is 0. Both L and R would be L + R. If L and R is the same, this would be a raise of 6dB. However, today I checked the panning in Ardour. When I adjust the width to 0% (mono), the amplitude raise by 3dB for each channel. So I adjust the two lines of width multiplication, take a squart root for the factor, and leave the rests same, final result should be like this:

M = (L+R)/sqrt(2); // obtain mid-signal from left and right
S = (L-R)/sqrt(2); // obtain side-signal from left and right

// amplify mid and side signal seperately:
M *= sqrt(2*(1-width));
S *= sqrt(2*width);

L = (M+S)/sqrt(2); // obtain left signal from mid and side
R = (M-S)/sqrt(2); // obtain right signal from mid and side

mystran
KVRAF
5384 posts since 12 Feb, 2006 from Helsinki, Finland

Re: Stereo expander algorithm?

Post Fri Oct 11, 2019 5:35 am

This is a very old thread, but the underlying assumption of equal power cross-fade (or panning) is that the original signals (ie. channels) are uncorrelated and similar gain. This holds reasonably well even for panning mono-signals, thanks to the unpredictability of acoustic summing, but it doesn't necessarily hold too well for M/S stereo control.

As it turns out, in the M/S stereo-width adjustment case, the "ideal" choice of the taper is highly signal dependent as more often than not the mid-channel is significantly stronger than the side-channel. For signals with weak side-channel, one could even argue that the ideal choice is to simply adjust the side-channel gain while leaving the mid-channel "as-is" where as for wide unison sounds or signals drowned in stereo reverb the equal power rule might indeed be a good choice.

Either way, the point I'm trying to make is that unlike panning (where equal power is almost always a reasonable choice), in this case the ideal choice is much less clear.

edit: however.. if you CAN make more assumptions for the source signal, then the situation changes... for example, choosing equal power might indeed be the optimal choice for a "width" knob for unison in a synthesiser, because here we can arrange for the original signals to be "uncorrelated" by hard-panning the voices (or spreading them across the stereo field in some other way)
If you'd like Signaldust to return, please ask Katinka Tuisku to resign.

Return to “DSP and Plug-in Development”