Skip to main content

SoundOptions <TName>

Type parameters

  • TName: string = string

Index

Properties

optionalbustCache

bustCache?: boolean

Optionally bust the cache on load

Default is false

optionalduration

duration?: number

Seconds?

By default unset, will play the natural length of the clip

optionalloop

loop?: boolean

Loop infinitely

optionalmaxConcurrentTracks

maxConcurrentTracks?: number

Maximum number of simultaneously playing tracks allowed for this single Sound. When the cap is reached, new play() calls are dropped and resolve to false. Default unset (unbounded).

optionalname

name?: TName

Optional explicit name for this sound. Used as the default key when this Sound is registered with a SoundManager (otherwise the basename without extension of the selected path is used, e.g. /sfx/coin.mp3 → coin).

If passed as a string literal, it is inferred as the Sound's name type parameter for strong typing.

optionalonPlay

Optional hook to wire custom Web Audio nodes (spatial panners, filters, reverb, analysers...) between this sound's source and its output. Runs each time a track (re)starts. See AudioGraphBuilder.

paths

paths: string[]
@param

A list of audio sources (clip.wav, clip.mp3, clip.ogg) for this audio clip. This is done for browser compatibility.

optionalpitch

pitch?: number

Pitch shift in cents (semitones are 100 cents). Default 0 (no change). Backed by AudioBufferSourceNode.detune; composes with Sound.playbackRate. Note: changing pitch also affects playback speed (this is a Web Audio limitation).

optionalplaybackRate

playbackRate?: number

Multiplyer

By default 1

optionalposition

position?: number

Advance to a position in the audio clip

optionalvoiceStealing

voiceStealing?: boolean

What happens when a maxConcurrentTracks cap *false (default) drops the new play *true stops the oldest playing track in that scope to make room for it.

optionalvolume

volume?: number

[0-1] 0% to 100%

By default 1 (100%)