Private
_playbackOptional
bufferPrivate
globalRetrieves the duration of the sound in seconds. If the sound is based on an AudioBuffer, it returns the duration of the buffer. Otherwise, if the sound has not been played and is a MediaElementSource, it returns NaN, indicating that the duration is unknown or not applicable.
The duration of the sound in seconds.
Returns a boolean indicating whether the object is currently playing. an object is playing if any of its playbacks are currently playing.
True if the object is playing, false otherwise.
Retrieves the current 3D spatial position of the sound in the audio context. The position is returned as an array of three values[x, y, z].
The current position of the sound.
Sets the 3D spatial position of the sound in the audio context. The position is an array of three values[x, y, z]. This method updates the position of all active playbacks of the sound.
The new position of the sound.
Gets the volume of the sound. This volume level affects all current and future playbacks of this sound instance. The volume is specified as a linear value between 0 (silent) and 1 (full volume).
The current volume of the sound.
Sets the volume of the sound. This volume level affects all current and future playbacks of this sound instance. The volume is specified as a linear value between 0 (silent) and 1 (full volume).
The new volume level for the sound.
Clones the current Sound instance, creating a deep copy with the option to override specific properties.
This method allows for the creation of a new, independent Sound instance based on the current one, with the
flexibility to modify certain attributes through the overrides
parameter. This is particularly useful for
creating variations of a sound without affecting the original instance. The cloned instance includes all properties,
playback settings, and filters of the original, unless explicitly overridden.
An object specifying properties to override in the cloned instance. This can include audio settings like volume, playback rate, and spatial positioning, as well as more complex configurations like 3D audio options and filter adjustments.
A new Sound instance that is a clone of the current sound.
Sets or retrieves the loop behavior for the sound. If loopCount is provided, the sound will loop the specified number of times. If loopCount is 'infinite', the sound will loop indefinitely until stopped. If no argument is provided, the method returns the current loop count setting.
Optional
loopCount: LoopCountThe number of times to loop or 'infinite' for indefinite looping.
The current loop count setting if no argument is provided.
Starts playback of the sound and returns a Playback instance representing this particular playback. Multiple Playback instances can be created by calling this method multiple times, allowing for the same sound to be played concurrently with different settings.
An array containing the Playback instances that have been started.
The base interface for any sound-producing entity, including individual sounds, groups, and playbacks. BaseSound