Audio · class
AudioListenerGraph
Explained in Your first game.
class AudioListenerGraphimport { AudioListenerGraph } from '@driftengine/audio';Constructor
new
constructor(mix: MixConsole)| Parameter | Type | Description |
|---|---|---|
mix | MixConsole |
Properties
| Name | Type | Description |
|---|---|---|
probe | OcclusionProbe | null | Set by the consumer; called by whatever wants to know if something is in the way. |
Accessors
| Name | Type | Description |
|---|---|---|
consoleget | MixConsole | The mix this listener belongs to. A source needs it for a bus and for the context. |
elapsedSecget | number | Seconds of listener time, accumulated from the frame steps it is given.MoreAccumulated rather than read off a clock, because nothing under this package may reach for
|
probeSlotsget | number | |
xget | number | |
yget | number | |
zget | number | |
velocityXget | number | |
velocityYget | number | |
velocityZget | number |
Methods
addZone
addZone(zone: ReverbZone): voidRegister a space this listener can be inside. See addReverbZone.
| Parameter | Type | Description |
|---|---|---|
zone | ReverbZone |
zoneSend
zoneSend(zone: ReverbZone): numberWhat that zone is currently being sent, from where the listener is standing.
| Parameter | Type | Description |
|---|---|---|
zone | ReverbZone |
claimProbeSlot
claimProbeSlot(): numberClaim 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): voidPlace and point the listener for this frame.
| Parameter | Type | Description |
|---|---|---|
x | number | |
y | number | |
z | number | |
yaw | number | |
pitch | number | |
dtSec | number |
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): voidMove the listener without it having travelled.
| Parameter | Type | Description |
|---|---|---|
x | number | |
y | number | |
z | number |
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.