Panning laws : Am I right ?

DSP, Plugin and Host development discussion.
Post Reply New Topic
RELATED
PRODUCTS

Post

Hi people ! :)

I'm currently coding, and I'm trying to figure out this panning law thing.

As far as I understood, linear panning is bad, because in the end you don't hear the same volume out of your speakers, right ?

I read that you have to use "constant power panning". After some maths and reading I came out with this piece of code :

Let's say that _crossValue is something between 0 (panned hard left) and 1 (panned hard right), and HALF_PI is ... PI/2 :-)

Code: Select all

switch(_xLaw)
		{
		case LINEAR:
			_gainChanel1 = 1 - _crossValue;
			_gainChanel2 = _crossValue;
			break;
				
		case SIN_COS:
			_gainChanel1 = sin((1 - _crossValue)*HALF_PI);
			_gainChanel2 = sin(_crossValue*HALF_PI);
			break;
}
Do you think it's right ?

However, with this code, in the SIN_COS statement, the sum of both chanels is > 1 when panned full center. I have 0.707 of gain per chanel, so in total it's approx 1.414

I read somewhere that using this SIN_COS law, makes the center being amplified by 3dB, and when I calculate 20*log(1.414), I also find 3

Makes sense so far !

My question, is : how should avoid this ?

I was thinking in simply multiplying each channel by 0,707, this way, when panned in full center, the sum of chanels is 1, so 20*log(1)=0 => no amplification !

But I wonder if there's any hidden trick ?

P.S. : I hope this post makes sense. I'm not sure !

Post

Sin/Cos between [0,pi/2] indeed gives you so called "-3dB center" constant power law: for any pan position, you will have sqrt(sin(x)^2+cos(x)^2)=1.

The sum of the two channels is irrelevant really, if we're aiming for constant power. If you wanted to keep the sum constant, you'd use the linear law, which gives -6dB peaks at center.

Now, returning to the -3dB "circular" law, if you want center panned signals to stay at 0dB, you can do this by scaling the whole thing by 3dB=sqrt(2). The side panned signals will then peak 3dB higher than the input. You see both scaled and unscaled panning laws around; it's mostly a matter of preference I guess.

edit: just to make the point clear, the difference between these two (and other) laws is what measure of signal "strength" they normalize. With linear law the sum stays constant, with sin-cos law the root of the sum of squares stays constant. You could also normalize other values and come up with other panning laws.

Post

Thanks for this detailed answer !

So equal power means that the sum of the squares must be constant, right ?

Now, when you say "Sin/Cos between [0,pi/2] indeed gives you so called "-3dB center" constant power law" , what does the "-3dB" mean ? Or better said, how do you calculate it ?

With the using the sin/cos formula, I got both gain left and gain right = 0,707 when panning is centered. Where from this can you tell it's -3dB ? :)

Post

dinaiz wrote: With the using the sin/cos formula, I got both gain left and gain right = 0,707 when panning is centered. Where from this can you tell it's -3dB ? :)
dB = 20*log10(rawAmplitude) = 20*log10(0.707) = -3.01
My website: rs-met.com, My presences on: YouTube, GitHub, Facebook

Post

Awesome, thanks !

Post

Ok, so when I look at the "peak" values :

With the linear law, I have 0 dB at the extremes pannings and - 6,02 dB at the center

With the sin/cos law, I have 0 dB at the extremes pannings and - 3,01 dB at the center

I took the 20* log10(raw amplitude) formula, "raw amplitude" being the amplitude of the loudest chanel.

Is it correct ?


Now, if we consider the -6dB center and -4,5 db center laws how do I calculate them ? I suppose it's not a matter of just multiplying raw amplitudes by a factor ... I guess the goal is to have 0 db on the sides and, respectively, -6 dB and - 4,5 dB on the center ? Does it means that the so-called "-6dB center law" is indeed, the linear one ?



Thanks for all your precious help !

Post

Ok I think I found the solution.

If I want my curve to peak at -6 dB when panned center, I need to have 20*log(new raw amplitude)=2 * 20 log(old raw amplitude)
Because log(a^x) = x log(a), new raw amplitude = old raw amplitude²

For -4,5 law, with the same thiking, new raw amplitude = old raw amplitude^1.5


- 3dB center law :
_gainChanel1 = sin((1 - _crossValue)*HALF_PI);
_gainChanel2 = sin(_crossValue*HALF_PI);

-4,5 dB center law :
_gainChanel1 = pow( sin((1 - _crossValue)*HALF_PI) , 1.5);
_gainChanel2 = pow( sin(_crossValue*HALF_PI), 1.5);

-6 dB center law :
_gainChanel1 = pow( sin((1 - _crossValue)*HALF_PI) , 2);
_gainChanel2 = pow( sin(_crossValue*HALF_PI), 2);

Post

Thank you for this thread dinaiz :)

Post Reply

Return to “DSP and Plugin Development”