Audio · interface

AmbienceOptions

A continuous environmental bed, built to loop without a seam.

Explained in Your first game.

interface AmbienceOptions
import 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

NameTypeDescription
secondsnumberLoop length. Longer costs memory but takes longer to recognise.
colournumberOne-pole low-pass coefficient, 0–1. Lower is darker.
bodyCutoptionalnumberSecond, slower follower subtracted from the first — a high-pass. Removes the rumble that otherwise dominates any heavily filtered noise.
swellDepthoptionalnumberSlow level movement: how deep, 0–1, and how many whole cycles per loop.
swellCyclesoptionalnumber
transientRateoptionalnumberSharp transients per second, and how fast each one decays.
transientDecayoptionalnumber
gainoptionalnumberPeak amplitude of the finished bed.