Audio · function
encodeFoa
Encode a mono signal arriving from a world direction into a first-order field.
Explained in Your first game.
function encodeFoa(gain: number, dirX: number, dirY: number, dirZ: number, out: Float32Array, at?: number): voidimport { encodeFoa } from '@driftengine/audio';Parameters
| Parameter | Type | Description |
|---|---|---|
gain | number | |
dirX | number | |
dirY | number | |
dirZ | number | |
out | Float32Array | |
at? | number |
In depth
dir need not be unit; it is normalised here, because a caller handing a difference of two
positions is the ordinary case and a caller who normalised first pays one square root twice.
A zero direction encodes as omnidirectional — all W, no direction — which is what a sound with
no bearing is, rather than a NaN.