Please assume:

Minimum distance for 3D volume = 1.0;
Maximum distance for 3D volume = 100.0;

This is the declaration of the function:

An object can be a ball moving closer to the player.

void CalculateSoundVolume(Vec3 objectPosition, 
                          Vec3 objectVelocity, 
                          Vec3 userHead, 
                          Vec3 userFoward, 
                          float& leftEarVolume, 
                          float& rightEarVolume)  


closed as off-topic by Josh Jul 30 '17 at 15:02

  • This question does not appear to be about game development within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • \$\begingroup\$ I know that I can linearly or logarithmically lower the volume based on the player's position relative to the object. With that lowered volume in hand, how would I calculate the amount of lowered volume to be applied to the right ear and left ear? \$\endgroup\$ – Nishanth Sundharesan Jul 30 '17 at 7:50
  • \$\begingroup\$ I'm voting to close this question as off-topic because it is a cross-post. \$\endgroup\$ – Josh Jul 30 '17 at 15:02
  • \$\begingroup\$ It's better to vote for the question in stack overflow rather than in game dev I believe. \$\endgroup\$ – Nishanth Sundharesan Jul 30 '17 at 19:45