Skip to content

registerSound

registerSound(alias, buffer): void

Defined in: audio/src/assets.ts:89

Register a runtime-generated AudioBuffer under an alias, so alias resolves and plays exactly like a preloaded sound — through the same AudioManager channels, mute, and blur auto-pause. This is the audio analogue of the renderer’s registerTexture(key, texture).

Registered aliases are engine-global, outside the asset manager’s ref counts and unloads, and live until unregisterSound. A game that stores an alias in its own save data must re-register its runtime sound before reconstructing playback.

Re-registering an alias this API still owns replaces the entry. An alias already used by a loaded sound asset (or one that overwrote a stale registration) throws: shadowing a loaded asset would let its unload destroy the registered sound later.

Callable at module scope, before AudioPlugin installs: the alias is held and added to the audio library when the plugin loads it.

const buffer = synthesizeShot(); // any code that produces an AudioBuffer
registerSound("shoot", buffer);
audio.play("shoot");

string

AudioBuffer

void