Audio · interface
AmbienceOptions
A continuous environmental bed, built to loop without a seam.
Explained in Your first game.
interface AmbienceOptionsimport type { AmbienceOptions } from '@driftengine/audio';In depth
Three things make a loop audible as a loop, and all three are handled here. The filters are warmed up before anything is recorded, so the buffer does not begin at silence and fade in. The join is crossfaded with equal-power weights, so the wrap has neither a click nor the ~3 dB hole a linear crossfade of noise leaves in the middle. And any slow swell is placed at a whole number of cycles per loop — the same reason the wind field uses integer harmonics — so it arrives back exactly where it started instead of turning the wrap into a lurch far more noticeable than the noise it rides on.
Properties
| Name | Type | Description |
|---|---|---|
seconds | number | Loop length. Longer costs memory but takes longer to recognise. |
colour | number | One-pole low-pass coefficient, 0–1. Lower is darker. |
bodyCutoptional | number | Second, slower follower subtracted from the first — a high-pass. Removes the rumble that otherwise dominates any heavily filtered noise. |
swellDepthoptional | number | Slow level movement: how deep, 0–1, and how many whole cycles per loop. |
swellCyclesoptional | number | |
transientRateoptional | number | Sharp transients per second, and how fast each one decays. |
transientDecayoptional | number | |
gainoptional | number | Peak amplitude of the finished bed. |