[ardour-dev] questions about panner.cc ...
Marc Vinyes
mvinyes at iua.upf.es
Thu Aug 25 14:34:47 PDT 2005
big thanks for your answers,
fons adriaensen wrote:
> On Thu, Aug 25, 2005 at 11:13:08AM -0400, Paul Davis wrote:
>
>
>>>I expected to see an attenuation of x in one channel and sqrt(1-x*x) in
>>>the other, but I saw:
>>>
>>> const float pan_law_attenuation = -3.0f;
>>> const float scale = 2.0f - 4.0f * powf
>>>//snip
>>> desired_left = panL * (scale * panL + 1.0f - scale);
>>> desired_right = panR * (scale * panR + 1.0f - scale);
>>>
>>>what is the purpose of this formula?
>>
>>it provides constant power panning (i.e. the total perceived volume
>>during panning remains the same), unlike the more simplistic approach
>>you mentioned, which tends to cause a dip or peak in perceived volume
>>during parts of a full panning sweep.
>
>
> x, sqrt (1-x*x) is also constant power, but not symmetrical around
> the centre.
yes it's also power constant, that's why I was asking...
I have looking at different links and documentation but you were the
first to say it: symmetry. thanks. that's indeed "the" point of it.
>
>
>>>BTW(not very important), wouldn't be better to replace powf
>>>(10.0f,pan_law_attenuation/20.0f) with 1/sqrt(2). and add a comment of
>>>//-3db attenuation
>>
>>could be. DSP has never been my thing, so i'd need someone else confirm
>>that this is indeed equivalent.
>
>
> It is. And both scale and 1-scale could just be replaced by constants.
I'd add that you can compute the value with a calculator to check it:
-6db is always considered as an aproximation of 20*log(1/2) (power
factor when a signal is scaled by 1/2 in amplitude)
and -3db represents 20*log(1/4) (power factor when a signal is scaled by
1/2 in power, which is equivalent to 1/sqrt(2) in amplitude).
>
> The scheme used is a (good) approximation to sin(), cos().
Uow, during my degree I only used taylor series to aproximate sin() and
cos() and this aproximation is just fantastic in the range of [0,pi/2]!
Do you know how did they get it? (does it minimize the norm error
between the parabola and the sin() perhaps?)
Finally I'd suggest to add comments to the code to explain it a little
bit. Just to make the next visitors enjoy browsing the source code ;)
I'd suggest
// implementation of constant power panning by
// desired_left= cos(x*PI/2)
// desired_right = sin(x*PI/2)
// cos() and sin() are aproximated by parabolas
I'd also remove the panR=x and use directly x and (1-x) but I wouldn't
merge the scale as maybe it has some reason to be written like this (if
I knew where the approximation comes from ....).
cheers
MarC
More information about the Ardour-Dev
mailing list