I'm facing the following 3D sound design pan problem. The idea is to calculate the normalized pan value [0...1] for a speaker when a floating orb moves from its original location in a chair.
Say I have a set of N points at the xyz space with specific coordinates and a floating orb at another specific xyz0 (chair). When the orb is located at this xyz0, then all the normalized pan values of the N points are 1.
When the orb is moved away from xyz0 to some position xyz1 then it approaches one or more of the speakers.
If the distance of a speaker from the xyz1 is less than the distance of the speaker from the xyz0, then the pan value for that speaker is 1.
My problem is to calculate the normalized pan value [0..1) for the speakers for which the new is larger than the distance from the chair.
I 've tried:
float ZeroDist = distance3d(SpeakerPos, ChairPos);
float CurrentDist = distance3d(SpeakerPos, OrbPos);
float v = CurrentDist - ZeroDist;
if (v <= 0)
Pan = 1;
else
Pan = 1 - (v / MaxSpeakerDistance);
However, this division with the max speaker distance doesn't seem correct. I get pan values higher than what expected. In this case, the max speaker distance is 4.
I 've also tried comparing the distance from the speaker in question to the speaker that is closer to the orb, but this yields weird results because when approaching one speaker, one speaker might be closer to the new orb position than the chair, so the pan is 1, but when the orb is moved again so the new orb distance from the speaker is larger than the chair, the pan might abruptly drop to zero.
I appreciate your help.
