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?

  • \$\begingroup\$ 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. \$\endgroup\$
    – DMGregory
    Jun 30, 2021 at 11:30

1 Answer 1


I think that finding parallels in real life can be helpful in finding the answer. Basically, there are two main factors to determine how loudly a sound is heard by an ear:

  1. The position of the ear relative to the sound
  2. The rotation of the ear relative to the sound (I.E. the shape of the ear and how sound bounces within it).

The latter might be too complex for us to figure out, but the former should be simple enough. If we know how to calculate volume for a specific point in space (I.E. (x1, y1, z1), and we know the ears are a bit apart (let's call this offset dX & dZ from the center of the head), so all we have to do is calculate the volume for each ear.

So, in general, if we have a function that we give a position to and it gives us the volume of sound in that position, we simply run that function on (x1 + dX, y1, z1 + dZ) and (x1 - dx, y1, z1 - dZ), and set the returning values as the volume levels for L and R respectively.

I hope that answers your question, or at least gives you a good starting point.

  • \$\begingroup\$ If you only use the difference in distance between the left and the right, without the orientation, you'll run into situations (e.g. when x1 and z1 are big) where the difference is very subtle and not audible, which would sound unnatural. \$\endgroup\$
    – Vaillancourt
    Jul 25, 2022 at 18:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .