What is KVR Audio? | Submit News | Advertise | Developer Account

Options (Affects News & Product results only):

OS:
Format:
Include:
Quick Search KVR

"Quick Search" KVR Audio's Product Database, News Items, Developer Listings, Forum Topics and videos here. For advanced Product Database searching please use the full product search. For the forum you can use the phpBB forum search.

To utilize the power of Google you can use the integrated Google Site Search.

Products 0

Developers 0

News 0

Forum 0

Videos 0

Search  

Panning laws : Am I right ?

DSP, Plug-in and Host development discussion.

Moderator: Moderators (Main)

dinaiz
KVRist
 
93 posts since 14 Nov, 2009

Postby dinaiz; Sun Oct 03, 2010 7:45 pm Panning laws : Am I right ?

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 !
mystran
KVRAF
 
4205 posts since 11 Feb, 2006, from Helsinki, Finland

Postby mystran; Sun Oct 03, 2010 11:11 pm

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.
Image <- plugins | forum
dinaiz
KVRist
 
93 posts since 14 Nov, 2009

Postby dinaiz; Mon Oct 04, 2010 8:36 am

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 ? :)
Robin from www.rs-met.com
KVRAF
 
3648 posts since 8 Mar, 2004, from Berlin, Germany

Postby Robin from www.rs-met.com; Mon Oct 04, 2010 9:14 am

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
Image
dinaiz
KVRist
 
93 posts since 14 Nov, 2009

Postby dinaiz; Mon Oct 04, 2010 9:20 am

Awesome, thanks !
dinaiz
KVRist
 
93 posts since 14 Nov, 2009

Postby dinaiz; Mon Oct 04, 2010 4:41 pm

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 !
dinaiz
KVRist
 
93 posts since 14 Nov, 2009

Postby dinaiz; Tue Oct 05, 2010 5:43 pm

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);
volkanozyilmaz
KVRist
 
35 posts since 16 Oct, 2004, from Istanbul / Turkey

Postby volkanozyilmaz; Fri Apr 04, 2014 12:25 am Re: Panning laws : Am I right ?

Thank you for this thread dinaiz :)

Moderator: Moderators (Main)

Return to DSP and Plug-in Development