2
$\begingroup$

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.

$\endgroup$
  • $\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
2
$\begingroup$

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

| improve this answer | |
$\endgroup$
  • $\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
1
$\begingroup$

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.

You can also expand the Blumlein idea (equal intensity) to incorporate any number of output channels that are equidistantly spaced on a circle of constant radius.

| improve this answer | |
$\endgroup$

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.