Plug-ins, Hosts, Apps,
Hardware, Soundware
Developers
(Brands)
Videos Groups
Whats's in?
Banks & Patches
Download & Upload
Music Search
KVR
   
KVR Forum » DSP and Plug-in Development
Thread Read
Panning laws : Am I right ?
dinaiz
KVRist
- profile
- pm
- e-mail
PostPosted: Sun Oct 03, 2010 7:45 pm reply with quote
Hi people ! Smile

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 Smile


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 !
^ Joined: 14 Nov 2009  Member: #219563  
mystran
KVRAF
- profile
- pm
- e-mail
- www
PostPosted: Sun Oct 03, 2010 11:11 pm reply with quote
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.
----
<- my plugins | my music -> @Soundcloud
^ Joined: 11 Feb 2006  Member: #97939  Location: Helsinki, Finland
dinaiz
KVRist
- profile
- pm
- e-mail
PostPosted: Mon Oct 04, 2010 8:36 am reply with quote
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 ? Smile
^ Joined: 14 Nov 2009  Member: #219563  
Robin from www.rs-met.com
KVRAF
- profile
- pm
- e-mail
- www
PostPosted: Mon Oct 04, 2010 9:14 am reply with quote
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 ? Smile

dB = 20*log10(rawAmplitude) = 20*log10(0.707) = -3.01
----
^ Joined: 08 Mar 2004  Member: #15959  Location: Berlin, Germany
dinaiz
KVRist
- profile
- pm
- e-mail
PostPosted: Mon Oct 04, 2010 9:20 am reply with quote
Awesome, thanks !
^ Joined: 14 Nov 2009  Member: #219563  
dinaiz
KVRist
- profile
- pm
- e-mail
PostPosted: Mon Oct 04, 2010 4:41 pm reply with quote
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 !
^ Joined: 14 Nov 2009  Member: #219563  
dinaiz
KVRist
- profile
- pm
- e-mail
PostPosted: Tue Oct 05, 2010 5:43 pm reply with quote
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);
^ Joined: 14 Nov 2009  Member: #219563  
All times are GMT - 8 Hours

Printable version
Page 1 of 1
Display posts from previous:   
ReplyNew TopicPrevious TopicNext Topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Username: Password:  
KVR Developer Challenge 2012