SoundTrack
Index
Constructors
constructor
Parameters
_buffer: AudioBuffer
The decoded audio to play
_destination: AudioNode
The node this track is wired into (the owning Sound's output)
optional_onPlay: AudioGraphBuilder
Optional hook that wires
source → destination, see AudioGraphBuilder
Returns SoundTrack
Properties
publicreadonlyid
Monotonically increasing id, older tracks have lower ids
publicscheduledStartTime
Audio context time in seconds at which the next (re)start is scheduled, 0 means immediately
Accessors
publicdone
Resolves when the track completes or is stopped
Returns Promise<boolean>
publicduration
The duration in seconds this track plays for, or the buffer's total duration when unset.
Note: the duration starts from the seeked position, seeking a 10 second clip to 5 seconds and setting a duration of 2 plays seconds 5-7.
Returns number
Parameters
duration: number | undefined
Returns void
publicloop
Loop infinitely, when changed the live source is updated
Returns boolean
Parameters
value: boolean
Returns void
publicpitch
Pitch shift in cents (a semitone is 100 cents), default 0. Backed by AudioBufferSourceNode.detune and composes with SoundTrack.playbackRate. Note: detune also changes playback speed, this is a Web Audio limitation.
Returns number
Parameters
pitch: number
Returns void
publicplaybackRate
Playback speed multiplier, default 1
Returns number
Parameters
playbackRate: number
Returns void
publicvolume
Volume [0-1] of this track only, multiplied with Sound.volume. Default 1.
Returns number
Parameters
value: number
Returns void
Methods
publicgetPlaybackPosition
Current position in the buffer in seconds
Returns number
publicgetTotalPlaybackDuration
Returns number
publicisPaused
Returns boolean
publicisPlaying
Returns boolean
publicisStopped
Returns boolean
publicpause
Returns void
publicplay
Start or resume playback, resolves when the track stops or completes
Parameters
playStarted: () => any = ...
Returns Promise<boolean>
publicseek
Move to a position in seconds, the track is paused until the next play()
Parameters
position: number
Returns void
publicstop
Returns void
A single playback of a Sound. Produced by
Sound.play(),Sound.start()andSound.seek(), see Sound.instances.Wraps a single-use Web Audio
AudioBufferSourceNoderouted through a per-track volume gain; a fresh buffer source is allocated each time the track (re)starts.https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API