利用者:NeXyon/GSoC2011/3D Audio/3D Device

提供: wiki
< 利用者:NeXyon‎ | GSoC2011‎ | 3D Audio
2012年2月8日 (水) 02:33時点におけるwiki>Mindronesによる版 (Software 3D Device Design)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先: 案内検索

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:

<math> \vec{SL} = \vec{LP} - \vec{SP} </math>

<math> vls = \frac{\vec{SL} \cdot \vec{LV}}{|\vec{SL}|} </math>

<math> vss = \frac{\vec{SL} \cdot \vec{SV}}{|\vec{SL}|} </math>

Clamp vls and vss to a maximum of <math> \frac{SS}{DF} </math>

<math> pitch = \frac{SS - DF \cdot vls}{SS - DF \cdot vss} </math>

Pitch

Input Variables:

  • SP = Source Pitch

Calculations:

<math> pitch = SP </math>

Distance

Input Variables:

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

Calculations:

<math> dist = |LP - SP| </math>

Here are three distance models possible with or without clamping.

In case of clamping:

<math> dist = max(min(max, dist), reference) </math>

Inverse Model:

<math> gain = \frac{ref}{ref + rof \cdot (dist - ref)} </math>

Linear Model:

<math> gain = 1- rof \cdot \frac{dist - ref}{max - ref} </math>

Exponential:

<math> gain = \left( \frac{dist}{ref} \right)^{-rof} </math>

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:

<math> \vec{LS} = \vec{SP} - \vec{LP} </math>

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

<math> t = \frac{phi - in}{out - in} </math>

t is clamped between 0 and 1

<math> gain = 1 + t \cdot (out - 1) </math>

Volume

Input Variables:

  • SV = Source Volume

Calculations:

<math> gain = SV </math>

3D-Cue

Input Variables:

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

Calculations:

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

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

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