# Calculating stereo sound levels from 3d sound source?

When a sound is emitted in a (first person) game world at some source position relative to the player - based on its distance away we can calculate the factor to multiply the amplitude of the wave that should be sent to the speakers from the inverse of the distance (in a unit of some appropriate "origin" base distance) - fine.

What I am not clear about is how to generate 2 channel stereo left/right sound.

(A) Let's say when the source is directly in front of the listener in the game world (and at the base distance away) we play the sound wave at the original recording amplitude in both speakers. Let's denote this by (L,R) = (1.0, 1.0).

(B) Now what if instead the sound source is directly to the right of the listener (and again base distance away). Clearly we play the sound louder in the right speaker than in the left one, right? But how much louder? Should the wave in the right speaker be louder than the wave in the right speaker in situation (A) ? What factor should we multiply the wave by in the left and right speaker? ie What should (L,R) be now?

(C) Now what if the source is at a 45 degree angle forward and off to the right of the listener ? What should (L, R) be in this situation?

How do you calculate (L,R) in general as a function of the relative source position and listener orientation?

• The term for this problem is "audio spatialization", and it's an area of ongoing research. If you want to go down the rabbit hole, you can look into things like HRTFs (Head-Related Transfer Functions) which try to model not just the different positions/orientations of the ears, but also the audio "shadow" cast by the head in between them, and how that alters the path sound needs to take to the far ear. This is used with headphones to get more convincing 3D positioning of sounds, especially in VR. Commented Jun 30, 2021 at 11:30