registerSound
registerSound(
alias,buffer):void
Defined in: audio/src/assets.ts:35
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. Snapshots store only the alias, so for save/load the game re-registers its runtime sounds under the same aliases before restoring (the same boot code that registered them on first run).
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.
const buffer = synthesizeShot(); // any code that produces an AudioBufferregisterSound("shoot", buffer);audio.play("shoot");Parameters
Section titled “Parameters”string
buffer
Section titled “buffer”AudioBuffer
Returns
Section titled “Returns”void