# Is there any simple algorithm to convert a sound source in 3d to volume and panning

I'm looking for a simple algorithm which calculates an approximation of volume and pan at the position of the camera from the following 3d data:

• Camera (position and look direction)
• An item which emits mono-audio at a specific position.

Just a basic approximation is enough for this case.

• Updated the question Commented Jan 10, 2020 at 14:55
• Yes, volume in left and right channel Commented Jan 10, 2020 at 16:14

• appears that you got the idea. let's assume that the vertical plane is at $\phi=0$ (we call $\phi$ the azimuth angle) and that the gain when the emitter is at distance $r_0$ is $G_0$. so the inverse "square" gain is $$G(r)= G_0\frac{r_0}{r}$$ assuming that the maximum left-right swing is $\pm 45^o$, then the Blumlein gain is $$R(\phi)=\sin(45^o+\phi)$$ and $$L(\phi)=\cos(45^o+\phi)$$ Commented Jan 11, 2020 at 17:01
If you want simple, you have to get rid of elevation (z-axis). If you want dead simple with two channels with a fixed range of motion, you can just take the square root of the panning width, normalized between $$0$$ and $$1$$: $$L = \sqrt{\phi_N} \\ R = \sqrt{1-\phi_N}$$
where $$\phi_N$$ is the angle, normalized from $$0$$ (hard left) to $$1$$ (hard right). "Turning around" is harder here.