Audio · class
AmbientLoop
Explained in Your first game.
class AmbientLoopimport { AmbientLoop } from '@driftengine/audio';Constructor
new
constructor(scheduleAt: ScheduleClock, source: AudioBufferSourceNode, gainNode: GainNode, panNode: StereoPannerNode | null)| Parameter | Type | Description |
|---|---|---|
scheduleAt | ScheduleClock | the instant this loop's changes land on. See ScheduleClock. |
source | AudioBufferSourceNode | the looping buffer source, already started. |
gainNode | GainNode | its level, initially silent. |
panNode | StereoPannerNode | null | present only where the browser supports stereo panning. |
Methods
setGain
setGain(gain: number): void0 is silent, 1 is the buffer at its authored level.
| Parameter | Type | Description |
|---|---|---|
gain | number |
setRate
setRate(rate: number): voidPitch the bed, for a loop whose state should be audible.
| Parameter | Type | Description |
|---|---|---|
rate | number |
More
Ramped like gain and pan rather than set, because a stepped playback rate on a continuous source is a click. Change-gated by the same rule: a rate written every frame would schedule sixty ramps a second.
setPan
setPan(pan: number): void-1 hard left, 0 centre, 1 hard right. A no-op without stereo panning.
| Parameter | Type | Description |
|---|---|---|
pan | number |
stop
stop(): void