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.

  • $\begingroup$ Updated the question $\endgroup$ – Viktor Sehr Jan 10 at 14:55
  • $\begingroup$ Yes, volume in left and right channel $\endgroup$ – Viktor Sehr Jan 10 at 16:14

inverse-square law for distance. and Blumlein stereo for pan.

  • $\begingroup$ ooops, inverse-square applies to power which is proportional to the square of gain. so it's just an inverse (a.k.a. "reciprocal") of distance to get the gain coefficient for both left and right. then a sine-cosine gain (that's the Blumlein thing) for panning left to right. $\endgroup$ – robert bristow-johnson Jan 10 at 16:47
  • $\begingroup$ So I calculate the distance between the camera and the sound emitter, then I pan the resulting volume according to how it's located relative an imaginary vertical plane pointing in the camera direction? $\endgroup$ – Viktor Sehr Jan 11 at 10:54
  • 1
    $\begingroup$ 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)$$ $\endgroup$ – robert bristow-johnson Jan 11 at 17:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.