# How to calculate the sound volume for the left ear and right ear based on the object position & velocity, player position & forward vector? (3D sound) [closed]

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 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.

• 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? – Nishanth Sundharesan Jul 30 '17 at 7:50
• I'm voting to close this question as off-topic because it is a cross-post. – Josh Jul 30 '17 at 15:02
• It's better to vote for the question in stack overflow rather than in game dev I believe. – Nishanth Sundharesan Jul 30 '17 at 19:45