Stereo Field Rotation Via Transformation Matrix

Type : Stereo Field Rotation
References : Posted by Michael Gruhn
Notes :
This work is hereby placed in the public domain for all purposes, including use in commercial applications.

'angle' is the angle by which you want to rotate your stereo field.
Code :
// Calculate transformation matrix's coefficients
cos_coef = cos(angle);
sin_coef = sin(angle);

// Do this per sample
out_left  = in_left * cos_coef - in_right * sin_coef;
out_right = in_left * sin_coef + in_right * cos_coef;

Comments
from : Foo
comment : If the source would be dead center a 180° rotation would mean the source would be behind you, but since in stereo there is no front or behind (just left and right), behind gets indicated by phase reversal (I know it doesn't reflect the position, but you can't because there is only left and right). Also the rotation is clockwise, so a positive angles shift the source to the right, which means for your example if you'd rotate from 0° to -90° you'd indeed get the signal one the left channel and the right blank. For a mono signal (both channels identical that is) and a rotation range of -45° to 45° is the same as panning (with a 0dB pan law). But I'll admit I was totally wrong and this entry in the musicdsp is the most faultiest that there ever was and isn't going to be useful at all, to no one. Anyway if this is not stereo field rotation, how would YOU call it? I'd happily forward the new terminology to the siteadmin, so the entries' description can be changed as soon as possible to whatever you think it is. I'm just glad that I'm not the only one that is using wrong terminology, e.g. the Waves S1-Imager's "Rotation" does the same as the above posted code, as does Nick Whitehurst's c_superstereo and others ... So tell me what it is called and I'll see if I can get the name changed, so everyone can be happy. Though I doubt I can get Waves nor any audio engineers to also adapt the new, correct terminology, that you will proved, for this kind of effect. BTW if you want to discuss this further please mail to: 1337foo42bar69@trashmail.net because there is no need to waste more comment space about this (I now think or at least hope that it only is a ...) terminology discussion, because there is nothing wrong with the code itself I posted, or is there?

from : Bar
comment : Yet another childish thought. If one can treat signals as if they were space locations, then surely translations will work just as well as rotations. So to move a sound source to another location, one just add constants to the signals?

from : Bar
comment : Let's try another experiment. You're in the midpoint of the line joining the two speakers and is the center of rotation. Your signal happens to have all zeros for the left channel. The formula simplifies to: out_left = -in_right * sin out_right = in_right * cos As you rotate from 0 to 90, sin goes from 0 to 1, cos goes from 1 to 0. So the formula predicts that the left channel goes from silence to a phase inverted right, and the right channel goes from full sound to silence. Whereas physically the sound should move from my right to directly in front of me. Please explain.

from : Bar
comment : Then I'm not sure what you mean by rotation. In my mind, I see two sound sources at arbitrary locations and I'm at the center of rotation. So the effect of a rotation would depend on the angle subtended by the three points to begin with, which doesn't even show up in the formula. Also please explains what does it mean by the two channels being orthogonal dimensions, which is what the formula is based on. (I assume you understand the mathematical basis of how the formula is derived.) No, a phase inversion on both channels don't sound 180 deg rotated. It sounds exactly the same as before.

from : Foo
comment : So you want mathematical prove? Even though I consider this childish, because it'd take you <5 minutes to put this in Matlab or any other DSP prototyping bench and hear the rotation effect for yourself. Anyway ... For 180° the output should be totally inverted. So: cos(180) = -1 sin(180) = 0 out_left = -in_left out_right = -in_right at 90° this means for a mono signal that the left channel will be a phase inverse of the right channel, so ... go directly to result, do not calculate: out_left = -in_right out_right = in_left at 45° is just like hard panning to the right (with a 3dB volume attenuation), so for a mono signal the expected results would be one channel silence and the other would have the signal, so we calculate: cos(45) = sqrt(2)/2 sin(45) = sqrt(2)/2 for mono signal we assume: mono = in_left = in_right ... so it follows: out_left = mono * sqrt(2)/2 - mono * sqrt(2)/2 = 0 out_right = mono * sqrt(2)/2 + mono * sqrt(2)/2 = mono * sqrt(2) == mono * 3dB and one more, 360° means same output as input, calculate for yourself. Valid enough?

from : Bar
comment : Sorry this makes no sense at all. The rotation formula is predicated on the assumption that (x,y) are coordinates of two orthogonal dimensions. Now you can choose to visualize stereo signals anyway you like, including being on a Cartesian plan, or as polar coordinates, what have you... But this visualization has no relationship to the physical location of the sound. The left and right channels are NOT orthogonal dimensions physically. What the formula does is just some weird panning. As the previous comment pointed out, just plug in some easy angles like 90, 180 ... and see if you can make any valid interpretations out of them. You can't.

from : Foo
comment : It IS the exact formula as rotation for a point in a 2D space (around its origin). Now this is applied to the stereo field. Imagine it as a left-right plot, so the values of the left and right channel get plotted (just like a goniometer: http://en.wikipedia.org/wiki/Goniometer_(audio)). So now you can see the stereo image (mono = straight line, stereo = circle, etc...). Now when you rotate THIS plot and then use the values of the rotated plot for the new left and right sample values, you rotated the stereo image. So just get a goniometer and look at how the signal changes when you run it through the algorithm, it will be pretty obvious. Hope this helps.

from : jgiulini[AT]hotmail[DOT]com
comment : This looks like the rotation formula for a point in space. Can you explain how does it work for a sound signal? Let's say that angle is 90 degrees, then you formula gives out_left = -in_right out_right = in_left How would this be a 90 deg rotation of the sound?

from : null
comment : Waves S1 Rotation, as you said, does exactly this. It is stereo field rotation, but in the same way could be considered panning. Thanks a lot for the useful code, it will be put to good use. :)

from : m[DOT]qafrund[AT]yahoo[DOT]de
comment : Alliance has announced that Brainworx bx_stereomaker is now avlaiable. I wrote about it in a previous post but here's some more information from the Plugin Alliance press release. Stereo by name,

from : sales[AT]pujol[DOT]co[DOT]uk
comment : on Wednesday its unemployment rate last year fell to a <a href="http://aaekhracmh.com">prvsioional</a> 3.2 per cent, the lowest since 2001, although the figure was flattered by a recent change in how the data was measured.The improving job data and a new government survey saying manufacturers were optimistic about the outlook for the first half of 2006 is expected to increase chances of the government calling a general election soon.In the fourth quarter, the unemployment rate fell to a seasonally adjusted 2.5 per cent due to a stronger economy and increased hiring in the services sector.However, the jobless rate among Singapore citizens and permanent residents remained higher at 3.3 per cent in the fourth quarter after peaking at 4.5 per cent in June.The government decided last year to revise the measurement of unemployment to include foreign workers who have temporary work permits, including construction workers living on site and those who commute to Singapore from Malaysia."The revision has the effect of reducing the overall unemployment rate as...(the) total labour force is now larger, taking into account full coverage of the foreign workforce," said the ministry of manpower, which compiles the statistics.Unemployment rates for foreign workers are lower since they normally lose their work permits and can no longer stay in Singapore if they become jobless.The ministry said the revision was needed to establish a common methodology for government statistical surveys.The jobless rate is closely watched when there is a growing debate about a widening gap between rich and poor, with elderly unskilled workers having a tougher time finding new jobs as Singapore moves towards higher-valued manufacturing.The government also recently revised upward last year's economic growth rate to 6 per cent from 5.7 per cent after it recalculated data, as it does every five years.Singapore's jobless rate before the 1997-98 Asian crisis was around 2 per cent, but climbed to a peak of 5.2 per cent in 2003 for residents before declining again.A recent recovery in manufacturing and stronger growth have cut the jobless rate in the last two years. The economy is expected to expand by at least 5 per cent this year, according to private economists.The number of new jobs increased to 110,000 last year, the strongest increase in nearly five years, due to a growing services sector and a recovery in construction.The government wants to add service jobs by opening two casino resorts to balance an overall decline in manufacturing jobs.Singapore's manufacturing sector employs about 18 per cent of the 2.1m workforce, down from a third in 1995, and more retrenchments are expected as companies shift production to China and Malaysia.Employment in the electronics sector, Singapore's biggest manufacturing industry, is expected to increase slightly this year due to increased global demand, the government said in its latest survey on business confidence among manufacturers.

from : paulhosk653241[AT]gmail[DOT]com
comment : Alliance has announced that Brainworx bx_stereomaker is now albavaile. I wrote about it in a previous post but here's some more information from the Plugin Alliance press release. Stereo by name, http://ycjqosr.com [url=http://pahjbb.com]pahjbb[/url] [link=http://cghasndpam.com]cghasndpam[/link]

from : xf8890087[AT]126[DOT]com
comment : Roger Let me try to explain a bit<a href="http://dgyosfax.com"> bteter</a>. Let's say I'm going to use a pad off my Yamaha Motif XS8. Most of them are stereo. But, if I turn off all the on board fx in the Motif I find that many of them are fine as mono. In that instance, I keep the fx off and just send the pad as mono to a mono audio track in Pro Tools. But, some pads have certain character in stereo even with all the fx turned off in the Motif. In that case, I will lay down the pad as a stereo audio in Pro Tools. In such a case, I find that even if I place both the pan knobs of that stereo track left or right that the over character of the sound remains more or less whole than if I just laid it down mono. In other words, the mono version just sounds different to me. Sometimes that's okay, but often not. So it depends on the situation and the sound I'm after. Also, I sometimes won't set the pans at the exact same level I might do 1 left 60 and the other left 45 or something. That can have a nice effect overall in the mix, but still keep the pan where I need it to be. There's no 1 right way on this, but just a way I've found that works. But to Graham's orginal point, totally agree: the more mono, the easier to get a good stereo mix! I can't tell you the number of times someone has sent me,say, their drum tracks and they would ALL be stereo! So I spend the first 1/2 hour or so converting everything to mono!

from : kchase[AT]boltonvalley[DOT]com
comment : Mixing everything streeo is like dancing by jumping just up and down on both feet, as opposed to going back, forth, left, right, up, down and everything inbetween.I remember someone calling it BIG MONO' for there is no movement between the channels.Panned mono tracks will not only make the music more interesting, because of the better perceived location and interaction between the instruments/musicians, but will also need less EQ power to separate the elements in the mix.EQ power that can then be put to better use , like enhancing the sonic quality of the tracks, (all within the context of the mix, of course).Especially when listening through headphones one will find oneself, even with the eyes closed, trying to follow the musical landscape with ones eyes.So, besides effectively making it sound big as Graham points out, there are more advantages to using as little possible streeo tracks. http://itgdqo.com [url=http://gjwjpjf.com]gjwjpjf[/url] [link=http://yzkautdb.com]yzkautdb[/link]

from : ifj1lff1sd[AT]gmail[DOT]com
comment : Don't make the error of considering when QuotesChimp are wholesome nowadays you will end up healthier tomorrow. Also if you're outwardly fit, you can incur an urgent medical problem, surgical procedure, or clinic keep anytime. From time this unforeseen state originates, it is going to be very tardy to procure medical insurance policy.

from : danielsan[DOT]ichiban[AT]gmail[DOT]com
comment : I just tried this out but as you rotate the field there are points where the field is flattened to become simply a mono signal rotated. visualize the output on a x/y vectorscope and perform the roation to see what I mean. I made a correction. The algorithm should be like this: r = rotation_angle out_left = (in_left * cos(r)) - (in_right * sin(r + pi)); out_right = (in_left * -sin(r)) - (in_right * cos(r + pi));

from : ffmusicdj[AT]gmail[DOT]com
comment : Why are you adding pi to the sin and cos at the end? What will adding 3.14 to the rotation do besides move the rotation angle further 3.14? IE if rotation angle is 90, you're just adding 3.14 to it equaling 93.14. Why only to the right channel? Shouldn't that cause problems? Wouldn't that mean that the reason this wont sound flat is because the calculations are 3.14 off?