Audio · class

AudioListenerGraph

Explained in Your first game.

class AudioListenerGraph
import { AudioListenerGraph } from '@driftengine/audio';

Constructor

new

constructor(mix: MixConsole)
ParameterTypeDescription
mixMixConsole

Properties

NameTypeDescription
probeOcclusionProbe | nullSet by the consumer; called by whatever wants to know if something is in the way.

Accessors

NameTypeDescription
consolegetMixConsoleThe mix this listener belongs to. A source needs it for a bus and for the context.
elapsedSecgetnumberSeconds of listener time, accumulated from the frame steps it is given.
More

Accumulated rather than read off a clock, because nothing under this package may reach for performance.now on a path a consumer might simulate, and because an offline render has no wall time at all — a mix rendered faster than real time still has to stagger its probes the same way the live one does.

probeSlotsgetnumber
xgetnumber
ygetnumber
zgetnumber
velocityXgetnumber
velocityYgetnumber
velocityZgetnumber

Methods

addZone

addZone(zone: ReverbZone): void

Register a space this listener can be inside. See addReverbZone.

ParameterTypeDescription
zoneReverbZone

zoneSend

zoneSend(zone: ReverbZone): number

What that zone is currently being sent, from where the listener is standing.

ParameterTypeDescription
zoneReverbZone

claimProbeSlot

claimProbeSlot(): number

Claim a probe slot. The index is what spreads one source's turn away from its neighbours'.

set

set(x: number, y: number, z: number, yaw: number, pitch: number, dtSec: number): void

Place and point the listener for this frame.

ParameterTypeDescription
xnumber
ynumber
znumber
yawnumber
pitchnumber
dtSecnumber
More

yaw 0 faces −Z and pitch is positive looking up, which is the convention every camera in this engine uses and the one stereoPan already documents. The two agree by construction here rather than by coincidence, so a source panned the cheap way and a source panned through a panner land on the same side of the head.

Velocity is derived rather than taken. A caller passing both a position and a velocity can make them disagree, and doppler needs only the component along the line to a source. Cost: a position that jumps reads as enormous speed, which is what warp and MAX_SPEED are between.

warp

warp(x: number, y: number, z: number): void

Move the listener without it having travelled.

ParameterTypeDescription
xnumber
ynumber
znumber
More

A teleport, a respawn, a camera cut. The next frame is measured from here, not from where the listener was, so nothing derives a speed from a jump that never happened.