Skip to content

eo-typewriterjs


eo-typewriterjs / AudioManagerHelper

Class: AudioManagerHelper ​

Defined in: core/audio/helpers/audio-manager.helper.ts:206

Description ​

Runtime audio manager for the typing sound system.

Handles sfx pack resolution, sample selection strategies (shuffle-bag, round-robin, random), volume/playback-rate jitter, overlap control, and graceful no-op in non-browser environments.

Create one instance per typewriter and keep it alive for the session. All settings can be mutated at runtime without restarting playback.

Constructors ​

Constructor ​

ts
new AudioManagerHelper(options?): AudioManagerHelper;

Defined in: core/audio/helpers/audio-manager.helper.ts:216

Parameters ​

ParameterTypeDescription
options?TAudioOptionsInitial audio configuration. Defaults to enabled with master volume 1 and the built-in sfx pack.

Returns ​

AudioManagerHelper

Description ​

Create a new AudioManagerHelper

Methods ​

ready() ​

ts
ready(): Promise<void>;

Defined in: core/audio/helpers/audio-manager.helper.ts:230

Returns ​

Promise<void>

A promise that resolves once playback can produce sound

Description ​

Wait until the samples needed by the current options are available. The built-in pack is loaded lazily the first time audio is enabled without custom sfxs; sounds requested before it has loaded are skipped.


setOptions() ​

ts
setOptions(options): void;

Defined in: core/audio/helpers/audio-manager.helper.ts:244

Parameters ​

ParameterTypeDescription
optionsTAudioOptionsThe new audio options to apply

Returns ​

void

Description ​

Replace the full audio configuration. Resets internal channel selection state so the new sfxs and strategy take effect immediately on the next play call.


setEnabled() ​

ts
setEnabled(enabled): void;

Defined in: core/audio/helpers/audio-manager.helper.ts:256

Parameters ​

ParameterTypeDescription
enabledbooleanWhether audio should be enabled

Returns ​

void

Description ​

Enable or disable audio globally at runtime


setVolume() ​

ts
setVolume(volume): void;

Defined in: core/audio/helpers/audio-manager.helper.ts:267

Parameters ​

ParameterTypeDescription
volumenumberNew master volume

Returns ​

void

Description ​

Set the master volume. Clamped to [0, 1].


getOptions() ​

ts
getOptions(): TAudioOptions;

Defined in: core/audio/helpers/audio-manager.helper.ts:277

Returns ​

TAudioOptions

The current TAudioOptions

Description ​

Return a snapshot of the current audio options


playTyping() ​

ts
playTyping(override?): void;

Defined in: core/audio/helpers/audio-manager.helper.ts:289

Parameters ​

ParameterTypeDescription
override?TAudioCommandOverrideOptional per-command audio override

Returns ​

void

Description ​

Play a typing (insert) sound. Pass a per-command override to use a specific sfx or volume for this keystroke. Pass false to silence this specific keystroke regardless of global settings.


playDelete() ​

ts
playDelete(override?): void;

Defined in: core/audio/helpers/audio-manager.helper.ts:300

Parameters ​

ParameterTypeDescription
override?TAudioCommandOverrideOptional per-command audio override

Returns ​

void

Description ​

Play a delete sound: the typing samples, pitched lower by default. Pass false to silence this specific deletion regardless of global settings.


playMove() ​

ts
playMove(override?): void;

Defined in: core/audio/helpers/audio-manager.helper.ts:311

Parameters ​

ParameterTypeDescription
override?TAudioCommandOverrideOptional per-command audio override

Returns ​

void

Description ​

Play a cursor move sound: the typing samples, lighter and quieter by default. Pass false to silence this specific move regardless of global settings.

Released under the MIT License.