From BlenderWiki

Jump to: navigation, search
Note: This is an archived version of the Blender Developer Wiki. The current and active wiki is available on wiki.blender.org.

Software 3D Device Design

Here's the signal-flow graph of the audio data:

NeXyon GSoC 2011 3d audio signal flow graph.png

The calculations how they are done in the specific steps follow, dopper and distance calculation formulars are from the OpenAL 1.1 Specification, the others are derived by me, so might contain errors atm.

Doppler

Input Variables:

  • SP = Source Position
  • SV = Source Velocity
  • LP = Listener Position
  • LV = Listener Velocity
  • SS = Speed of Sound
  • DF = Doppler Factor

Calculations:

 \vec{SL} = \vec{LP} - \vec{SP}

 vls = \frac{\vec{SL} \cdot \vec{LV}}{|\vec{SL}|}

 vss = \frac{\vec{SL} \cdot \vec{SV}}{|\vec{SL}|}

Clamp vls and vss to a maximum of  \frac{SS}{DF}

 pitch = \frac{SS - DF \cdot vls}{SS - DF \cdot vss}

Pitch

Input Variables:

  • SP = Source Pitch

Calculations:

pitch = SP

Distance

Input Variables:

  • ref = Reference Distance
  • rof = Rolloff Factor
  • max = Maximum Distance
  • SP = Source Position
  • LP = Listener Position

Calculations:

dist = | LPSP |

Here are three distance models possible with or without clamping.

In case of clamping:

dist = max(min(max,dist),reference)

Inverse Model:

 gain = \frac{ref}{ref + rof \cdot (dist - ref)}

Linear Model:

 gain = 1- rof \cdot \frac{dist - ref}{max - ref}

Exponential:

 gain = \left( \frac{dist}{ref} \right)^{-rof}

Cone

Input Variables:

  • SZ = Lookat of the Source
  • LP = Listener Position
  • SP = Source Position
  • in = Inner Cone Angle
  • out = Outer Cone Angle
  • og = Outer Cone Gain

Calculations:

 \vec{LS} = \vec{SP} - \vec{LP}

 phi = arccos \left( \frac{\vec{SZ} \cdot \vec{LS}}{|\vec{SZ}| |\vec{LS}|} \right)

 t = \frac{phi - in}{out - in}

t is clamped between 0 and 1

 gain = 1 + t \cdot (out - 1)

Volume

Input Variables:

  • SV = Source Volume

Calculations:

gain = SV

3D-Cue

Input Variables:

  • S = Source Position
  • N = Listener Up Vector
  • C = Listener Position
  • Z = Listener Look at Vector

Calculations:

 \vec{A} = \vec{S} + \frac{(\vec{C} - \vec{S}) \cdot \vec{N}}{\vec{N}^2} \cdot \vec{N} - \vec{C}

 phi = arccos \left( \frac{\vec{Z}\vec{A}}{|\vec{Z}| |\vec{A}|} \right) \cdot sgn( (\vec{N} \times \vec{Z} ) \vec{A} )

phi is then used to decide which speakers the audio signal is played to.