When Casey began addressing the issues in GitHub, I saw the one about "wrong pitch" and just assumed it had to do with the audio mixer, so I set out to look at the audio code to see if I could find it. Turns out, of course, that the issue had nothing to do with audio.. :)
but, in the process I did discover that there is an issue with the way panning is calculated.
Casey implemented linear panning, which looks like this:
http://imgur.com/a/W0ZqI
The problem with linear panning is that it does not maintain the same intensity level of the audio across the panning field. Panning full left or full right will have full intensity, but towards the centre, if you listen carefully, the intensity will dip, and as the audio pans from L -> R and vice versa it will seem to get "pulled" into the L/R speakers. The reason is that at the centre, both channels are at 0.5 amplitude, but amplitude values of 0.5 + 0.5 does not equal full intensity. The amplitude of sound is not really a good measure of how we perceive loudness, which is why the dB scale is so important and why the root-mean-square value is a more accurate measurement of how we perceive loudness.
So as opposed to linear panning, constant power panning maintains intensity across the whole panning field:
http://imgur.com/a/fZcOk
The equations for calculating the panning for L/R are:
| L = (sqrt(2) / 2) * (cos(x) - sin(x))
R = (sqrt(2) / 2) * (cos(x) + sin(x))
|
where x is the panning angle in radians.
So you would just need to map the panning value of -1 -> 1 into -pi/4 -> pi/4 radians (giving the total panning field a value of pi / 2), and then calculate the L/R panning given the equations above.
| angle = panning * (pi / 4)
|
We haven't looked at the audio code in a long time, but I thought I would bring this up as Casey has been doing some bug fixes lately. And computationally speaking it's not much more expensive than the linear panning that's in there now, so hopefully you think it's worth it, Casey. :)