Scriber.Ambience (Scriber v0.1.2)

Copy Markdown View Source

The dungeon ambience bed: a seeded, loopable drone for one depth.

Three parts play at once: two held tones a fifth apart, a slow breath of filtered noise, and occasional distant drips and rumbles placed by chance. The random placement is seeded from the depth, so a given depth always sounds the same.

Depth darkens the bed. Deeper levels lower the drone's root, raise the breath's gain, and make the distant sounds more frequent. The darkening saturates: beyond depth 8 the bed stops changing.

duration/0 gives the bed's length in seconds; rendering one with loop/2 takes far longer than playing the score with score/2 does to start.

Example

Scriber.Ambience.score(3, 1.0)
Scriber.Ambience.loop(3, 0.8)

Summary

Functions

How long the bed runs, in seconds. The same for every depth.

The bed for depth rendered to PCM and normalised to a fixed quiet loudness.

The same bed as loop/2, as an unrendered TuningFork.Score for live playback.

Functions

duration()

@spec duration() :: float()

How long the bed runs, in seconds. The same for every depth.

loop(depth \\ 1, gain \\ 1.0)

@spec loop(pos_integer(), float()) :: binary()

The bed for depth rendered to PCM and normalised to a fixed quiet loudness.

gain scales every part before rendering. Rendering is expensive — far longer than the bed's own duration/0 — so callers should cache the result rather than render per descent.

score(depth \\ 1, gain \\ 1.0)

@spec score(pos_integer(), float()) :: TuningFork.Score.t()

The same bed as loop/2, as an unrendered TuningFork.Score for live playback.

gain scales every part. Playing this starts immediately where loop/2 must synthesise first, at the cost of the loudness normalisation loop/2 applies; the playing stage's own reverb stands in for the per-part rooms.