Repository navigation
API Variable Audio
const Audio: object;Defined in: src/plugins/audio/runtime/Audio.ts:55
One-shot and global audio helpers.
snapshot: (name, fadeSeconds?) => AudioSnapshot = snapshotOf;A snapshot of the project's mix by name (ADR 0344): Audio.snapshot("Underwater").start() and .stop() fade it in
and out over its own times, blending with the other snapshots on (priority, Override or Add). With fadeSeconds,
the shorthand: fade to it over that time, fading out the other snapshots game code started.
Audio.snapshot(name): the snapshot's handle; Audio.snapshot(name, fadeSeconds): the shorthand (fade to it), and its handle.
string
number
get buses(): readonly string[];Names of the project's buses.
readonly string[]
get calibration(): number;Seconds, default 0: subtracted from an input's offset (judged = offset - calibration). Kept per output device.
number
set calibration(seconds): void;number
void
get calibrationStale(): boolean;True after the output device changed, until a new calibration is set; the old value is kept meanwhile.
boolean
get capture(): AudioCapture;Record a take of the mix for the Profiler: await Audio.capture.start(), then Audio.capture.save(). The recorder
loads on the first start(); a game that never calls it loads nothing.
get dialogue(): AudioDialogue;ADR 0355 §5: the speaker channels and the dialogue memory.
AudioDialogue
get horizon(): number;Seconds, read-only: the earliest heard time a stamped start is exact for a decoded clip (now + lookahead). Not a
promise for a streamed clip (those need priming). On a backend without it: Audio.time.
number
get language(): string;The current audio language (a shipped voice language's code). Setting it is void Audio.setLanguage(code).
string
set language(code): void;string
void
get languages(): readonly AudioLanguage[];The shipped voice languages: code, name and own fallbacks.
readonly AudioLanguage[]
get latency(): AudioLatency;Seconds, read-only: base, output and limiter latency, their total, and whether the output figure is reliable.
get loudnessTarget(): string | null;The entry of audio.loudnessTargets the loudness meters check against (default the first); an unknown name is ignored with one warning.
string | null
set loudnessTarget(name): void;string | null
void
get masterVolume(): number;Same property as volume; kept.
number
set masterVolume(v): void;number
void
get muted(): boolean;Mute everything.
boolean
set muted(m): void;boolean
void
get packages(): readonly AudioPackage[];ADR 0351 §9: every package this game has for its platform, in audio.json's order.
readonly AudioPackage[]
get pendingLanguage(): string | null;The language a switch in progress goes to; null when none is.
string | null
get rhythmMode(): boolean;Read-only: the project's audio.rhythmMode setting.
boolean
get status(): AudioStatus;"locked" until the browser allows audio, "running", or "failed".
get subtitleLanguage(): string | null;The language subtitles resolve in; null (default) follows the text language (Locale.language).
string | null
set subtitleLanguage(code): void;string | null
void
get take(): AudioTake;ADR 0348: record a take of the game run for the audio designer: what the game asked of audio and the engine's profile,
in one *.sporesample file. await Audio.take.start(), Audio.take.mark("boss"), then Audio.take.save(). The recorder
loads on the first start(); a game that never calls it loads nothing.
get time(): number;The heard audio clock in seconds: 0 before the context runs; independent of game pause and Time.scale; updated once per frame.
number
get volume(): number;Master volume, 0..1. New alias of masterVolume (ADR 0157 delta D1).
number
set volume(v): void;number
void
bus(name): Bus;A mixer bus by name (ADR 0097): Audio.bus("Music").volume = 0.5.
string
clearSnapshot(fadeSeconds?): void;Fade out every snapshot game code started (the shorthand's way back to the plain mix). Default fade 0.5 s.
number
void
debug(): AudioDebugState;A copy of the state for tools and "why is there no sound?". Allocates; never per frame.
AudioDebugState
getParameter(name): string | number | undefined;A global audio parameter's value (a label for labelled ones); undefined if there is none by that name.
string
string | number | undefined
line(key, options?): AudioLineHandle;ADR 0354 §5: play a voice-over line by key (keys are unique across the project's line tables), through its table's
template or as a one-shot Clip on its table's output, in the current language's file (falling back through its
chain). A line no language has runs subtitle-only for its reading time (localisation.missing: "subtitleOnly"). An
unknown key gives an inert handle with reason "unknownLine". Plays now (no queueing: Audio.say has channels).
Never throws.
string
onCaption(fn): () => void;ADR 0357 §4: hear the captions of playlists that have one, as their instances start sounding and end. Returns the unsubscribe.
(e) => void
() => void
onLine(fn): () => void;ADR 0354 §5: hear every line's start, end and Cue marker events, with its subtitle. Returns the unsubscribe.
(e) => void
() => void
package(name): AudioPackage;ADR 0351 §9: a package of sounds from audio.json (Wwise's SoundBanks, FMOD's banks): await Audio.package("Forest").load()
before playing its sounds, unload() when they're done. Loads are reference-counted; an unknown name gives a handle
whose load() rejects, with one warning. With strict packaging (the default) a packaged sound whose packages are all
unloaded doesn't play: its handle's reason is "notLoaded".
string
play(pathOrSample, options?): AudioPlaylistHandle;Play a playlist (*.playlist.json, ADR 0343), a sample or a sound generator (*.generator.json, ADR 0360; each as a
one-entry Clip playlist). Always returns a handle (an
inert one when nothing played: no World with the view, a missing asset, a trigger the playback rules refused, or an
old audio event file, which is refused with a message naming the migration; Audio.debug().playlistTotals says
why); never throws.
string
playOneShot(clip, options?): AudioHandle;Start a clip once. A bare number is the volume. Always returns a handle (refused or failed plays give an inert one with playing false); never throws.
string
number | OneShotOptions
say(event, options?): AudioLineHandle;ADR 0355 §5: say a dialogue event: it picks a line by best match over its arguments (options.args, else the
global parameters, else the defaults) and speaks it on a speaker channel, with priority, interruption, queueing,
cooldowns and memory. An unknown event gives an inert handle with reason "unknownEvent". Never throws.
string
setLanguage(code, options?): Promise<void>;Switch the audio language atomically: the new language's package parts load first, then Audio.language changes
in one step and is remembered (player storage, when the project remembers it). playing: "finish" (default) lets
voice-over playing in the old language finish; "stop" stops it with a 50 ms fade. An unknown or unshipped code
rejects with one warning and changes nothing; a later switch supersedes a pending one.
string
SetLanguageOptions
Promise<void>
setParameter(name, value): void;Set a global audio parameter (the Studio's Parameters; labelled ones by label). Snapshots started by conditions on it follow (ADR 0344).
string
string | number
void
timeAt(performanceTime): number;The raw heard time (seconds, Audio.time's base) of a performance.now() instant in ms, such as event.timeStamp.
Calibration is never applied here. Audio.time before the clock has an estimate.
number
number
This wiki is generated from docs/wiki/ and the myco module's source on every push to master. Change pages there in a pull request: edits made here are not kept.
Basics
Gameplay
Rendering
Audio
- Playing sound
- Why is there no sound?
- Playlists
- Interactive music
- Sound generators
- Spatial audio
- Audio mixer
- Live mixing
- Loudness
- Audio profiler
- Audio takes
Reference