[LAU] cross fade with equal power

Robin Gareus robin at gareus.org
Sat Feb 15 00:59:29 CET 2020


On 2/15/20 12:19 AM, Will Godfrey wrote:

> This is what I use for near constant power panning. Any good?
> float t = (float)(GlobalPar.PPanning - 1) / 126.0f;
> pangainL = cosf(t * Pi/2);
> pangainR = cosf((1.0f - t) * Pi/2);

Why cosine? You might want to use sinus curve as deflection
`t = sin(t * M_PI/2)`, but since signal-power is proportional to the
square of the signal [1], for equal power pan you want square root:

  gainL = sqrtf (t) / DB3
  gainR = sqrtf (1.f - t) / DB3

where #define DB3 1.4125375 // 10^(3/20)

> Where GlobalPar.PPanning is in the range 0 - 127
> It actually gives a 3dB hump in the middle

You should attenuate the signal by 3dB to prevent clipping, or maybe
only 2.5dB or perhaps 4.5dB, 4.2dB is also not unheard of:

http://admiralbumblebee.com/music/2019/12/08/Daw-V-Daw-Pan-Curves.html

Cheers!
robin


[1] Power is P = U * I
plug in Ohm's Law: R = U / I
P = U^2 / R


More information about the Linux-audio-user mailing list