Skip to main content
cngx-src documentation

CngxAudioEngine

Interface

projects/common/audio/engine/audio-engine.ts

Import#

import { CngxAudioEngine } from '@cngx/common/audio'

Description#

The audio engine surface. A single write path for muted / volume (no mute()/unmute() pair); every state change is a reactive Signal.

Index#

Instance Properties#

lastPlayed#Signal
Readonly

Name of the last earcon actually played, or null. Powers e2e + debug.

muted#Signal
Readonly

true when globally muted.

status#Signal
Readonly

Shared-context lifecycle state.

volume#Signal
Readonly

Master volume in [0, 1].

Methods#

armAutoplay#void

Arm the autoplay gate programmatically and resume the context if possible.

play#void
play(name: string, scale?: number)

Play a registered earcon by name. Gated + debounced centrally here. scale (a [0, 1] multiplier over the per-tone default) scales just this play — used by the directives' per-element audioVolume without touching the shared master volume.

@paramnamestring
@paramscale?number
register#void
register(name: string, config: EarconConfig)

Register or override an earcon at runtime.

@paramnamestring
@paramconfigEarconConfig
sequence#void
sequence(steps: unknown, scale?: number)

Play an ad-hoc tone sequence. Gated, not debounced. scale as in tone.

@paramstepsunknown
@paramscale?number
setMuted#void
setMuted(muted: boolean)

Set the global mute state.

@parammutedboolean
setVolume#void
setVolume(volume: number)

Set master volume, clamped to [0, 1].

@paramvolumenumber
tone#void
tone(freq: number, durationMs: number, opts?: ToneOptions, scale?: number)

Play a single ad-hoc tone. Gated, not debounced, no lastPlayed update. scale is the same [0, 1] multiplier play() takes and is applied over opts.gain (or the per-tone default) by the engine.

@paramfreqnumber
@paramdurationMsnumber
@paramopts?ToneOptions
@paramscale?number