The game's audio: a Cauldron2D.Audio instance of the application's own, the ambience
bed switched as the player descends, and the voice of every event Scriber.Game emits.
Playback, mixing and caching are Cauldron2D.Audio's; the beds themselves are
Scriber.Ambience's. What lives here is which bed belongs to which stratum, and what
each event sounds like: footsteps, a creature's step and chatter and cry where it
stands, the hit of each weapon on each kind of creature, misses, parries, stuns, deaths,
pickups, the gate, the drop.
Events placed with a position are played against the player's position by the audio
instance, fading with distance and panned by side; play/3 sets the listener and
plays a frame's events in one go.
Setting SCRIBER_QUIET to any non-empty value makes start/2 answer nil, and every
other function is a no-op on nil, so the game runs silent without checking.
Example
audio = Scriber.Sound.start(1)
Scriber.Sound.descend(audio, 2)
Scriber.Sound.mute(audio, true)
Scriber.Sound.stop(audio)
Summary
Functions
Switch the ambience to depth's bed, replacing whatever is playing.
Set the ambience volume. gain runs from 0.0 (silent) to 1.0 (full).
Silence all audio when muted? is true, restore it when false.
Whether the instance has a stage with somewhere to play.
Set where the player stands and sound the frame's events.
Start an audio instance linked to the caller and begin depth's ambience.
Stop the instance and its stage.
What an event sounds like: a voice, a run of {delay_ms, voice}, or nil for silence.
Types
@type t() :: pid() | nil
Functions
@spec descend(t(), pos_integer()) :: :ok
Switch the ambience to depth's bed, replacing whatever is playing.
The score starts immediately while the rendered bed is built off to the side and cached on disk, so only the first visit to a depth pays the rendering cost.
Set the ambience volume. gain runs from 0.0 (silent) to 1.0 (full).
Silence all audio when muted? is true, restore it when false.
Whether the instance has a stage with somewhere to play.
Set where the player stands and sound the frame's events.
@spec start(pos_integer(), keyword()) :: t()
Start an audio instance linked to the caller and begin depth's ambience.
opts are Cauldron2D.Audio.start_link/1's, :sink above all; the stage's settings are
set here. Returns the instance, or nil when SCRIBER_QUIET is set.
@spec stop(t()) :: :ok
Stop the instance and its stage.
@spec voice(term()) :: Cauldron2D.Audio.sound()
What an event sounds like: a voice, a run of {delay_ms, voice}, or nil for silence.