API reference

Every public class, method, and event in @codexo/exojs. Generated from source.

C

classSound

@codexo/exojs / audio / stable

Pre-decoded short audio clip backed by an `AudioBuffer`. Each Sound.play call grabs a free `AudioBufferSourceNode` from the pool (default size 8) so the same sound can overlap itself; when the pool is full the configured SoundPoolStrategy decides which source to evict. Supports audio-sprite playback via Sound.playSprite — name a sub-region in the AudioSpriteClip options and trigger by name. Routes through any AudioBus; defaults to the engine's `sound` bus. Calling Sound.makeSpatial attaches a panner so the sound follows a SceneNode or world-space target with distance attenuation handled by Web Audio. Use Music for long-form streaming audio (single source, decoded lazily) — `Sound` is best for short, frequently-triggered clips.

21
props
25
methods
2
events
Import
import { Sound } from '@codexo/exojs'

Pre-decoded short audio clip backed by an `AudioBuffer`. Each Sound.play call grabs a free `AudioBufferSourceNode` from the pool (default size 8) so the same sound can overlap itself; when the pool is full the configured SoundPoolStrategy decides which source to evict.

Supports audio-sprite playback via Sound.playSprite — name a sub-region in the AudioSpriteClip options and trigger by name.

Routes through any AudioBus; defaults to the engine's `sound` bus. Calling Sound.makeSpatial attaches a panner so the sound follows a SceneNode or world-space target with distance attenuation handled by Web Audio.

Use Music for long-form streaming audio (single source, decoded lazily) — `Sound` is best for short, frequently-triggered clips.

Constructors 1
new(audioBuffer: AudioBuffer, options: SoundOptions): Sound
Methods 25
_connectToBus(): void
_defaultBus(): AudioBus
_disconnectFromBus(): void
_getAudioSetup(): object | null
_tickSpatial(): void
applyOptions(options: Partial<PlaybackOptions>): this
defineSprite(name: string, clip: AudioSpriteClip): this
destroy(): void
fadeIn(durationMs: number): this
fadeOut(durationMs: number, options: object): this
getTime(): number
hasSprite(name: string): boolean
pause(options?: Partial<PlaybackOptions>): this
play(options?: PlayOptions): this
playSprite(name: string, options: Partial<PlaybackOptions>): this
removeSprite(name: string): this
setLoop(loop: boolean): this
setMuted(muted: boolean): this
setPlaybackRate(value: number): this
setPoolSize(poolSize: number): this
setSprites(sprites: Readonly<Record<string, AudioSpriteClip>>): this
setTime(currentTime: number): this
setVolume(value: number): this
stop(options?: Partial<PlaybackOptions>): this
toggle(options?: Partial<PlaybackOptions>): this
Properties 21
analyserTarget: GainNode | null
audioBuffer: AudioBuffer
bus: AudioBus
currentTime: number
distanceModel: DistanceModel
duration: number
loop: boolean
maxDistance: number
muted: boolean
paused: boolean
playbackRate: number
playing: boolean
poolSize: number
poolStrategy: SoundPoolStrategy
position: Vector | null
priority: number
progress: number
refDistance: number
rolloffFactor: number
velocity: Vector | null
volume: number
Events 2
onStart: Signal<[]>
onStop: Signal<[]>
Source