Create a new SoundInstance3d instance.
The sound manager.
The sound to play.
Options for the instance.
Determines which algorithm to use to reduce the volume of the audio as it moves away from the listener. Can be:
Defaults to DISTANCE_LINEAR.
The total time after the startTime when playback will stop or restart if loop is true.
Whether the sound should loop when it reaches the end or not. Defaults to false.
The maximum distance from the listener at which audio falloff stops. Note the volume of the audio is not 0 after this distance, but just doesn't fall off anymore. Defaults to 10000.
The relative pitch. Defaults to 1 (plays at normal pitch).
The position of the sound in 3D space.
The reference distance for reducing volume as the sound source moves further from the listener. Defaults to 1.
The factor used in the falloff equation. Defaults to 1.
The time from which the playback will start. Default is 0 to start at the beginning.
The playback volume, between 0 and 1. Defaults to 1.
Gets the source that plays the sound resource. If the Web Audio API is not supported the type of source is Audio. Source is only available after calling play.
Gets the current time of the sound that is playing.
Sets the current time of the sound that is playing. If the value provided is bigger than the duration of the instance it will wrap from the beginning.
Gets which algorithm to use to reduce the volume of the audio as it moves away from the listener.
Sets which algorithm to use to reduce the volume of the audio as it moves away from the listener. Can be:
Default is DISTANCE_LINEAR.
Gets the duration of the sound that the instance will play starting from startTime.
Sets the duration of the sound that the instance will play starting from startTime.
Gets whether the instance is currently paused.
Gets whether the instance is currently playing.
Gets whether the instance is currently stopped.
Gets whether the instance is currently suspended because the window is not focused.
Gets whether the instance will restart when it finishes playing.
Sets whether the instance will restart when it finishes playing.
Gets the maximum distance from the listener at which audio falloff stops.
Sets the maximum distance from the listener at which audio falloff stops. Note that the volume of the audio is not 0 after this distance, but just doesn't fall off anymore.
Gets the pitch modifier to play the sound with.
Sets the pitch modifier to play the sound with. Must be larger than 0.01.
Gets the reference distance for reducing volume as the sound source moves further from the listener.
Sets the reference distance for reducing volume as the sound source moves further from the listener.
Gets the factor used in the falloff equation.
Sets the factor used in the falloff equation.
Gets the start time from which the sound will start playing.
Sets the start time from which the sound will start playing.
Gets the volume modifier to play the sound with. In range 0-1.
Sets the volume modifier to play the sound with. In range 0-1.
Clears any external nodes set by SoundInstance#setExternalNodes.
Fire an event, all additional arguments are passed on to the event listener.
Name of event to fire.
Optional
arg1: anyFirst argument that is passed to the event handler.
Optional
arg2: anySecond argument that is passed to the event handler.
Optional
arg3: anyThird argument that is passed to the event handler.
Optional
arg4: anyFourth argument that is passed to the event handler.
Optional
arg5: anyFifth argument that is passed to the event handler.
Optional
arg6: anySixth argument that is passed to the event handler.
Optional
arg7: anySeventh argument that is passed to the event handler.
Optional
arg8: anyEighth argument that is passed to the event handler.
Self for chaining.
Gets any external nodes set by SoundInstance#setExternalNodes.
Returns an array that contains the two nodes set by SoundInstance#setExternalNodes.
Detach an event handler from an event. If callback is not provided then all callbacks are unbound from the event, if scope is not provided then all events with the callback will be unbound.
Optional
name: stringName of the event to unbind.
Optional
callback: HandleEventCallbackFunction to be unbound.
Optional
scope: objectScope that was used as the this when the event is fired.
Self for chaining.
const handler = function () {
};
obj.on('test', handler);
obj.off(); // Removes all events
obj.off('test'); // Removes all events called 'test'
obj.off('test', handler); // Removes all handler functions, called 'test'
obj.off('test', handler, this); // Removes all handler functions, called 'test' with scope this
Attach an event handler to an event.
Name of the event to bind the callback to.
Function that is called when event is fired. Note the callback is limited to 8 arguments.
Optional
scope: object = ...Object to use as 'this' when the event is fired, defaults to current this.
Can be used for removing event in the future.
Attach an event handler to an event. This handler will be removed after being fired once.
Name of the event to bind the callback to.
Function that is called when event is fired. Note the callback is limited to 8 arguments.
Optional
scope: object = ...Object to use as 'this' when the event is fired, defaults to current this.
Connects external Web Audio API nodes. You need to pass the first node of the node graph that you created externally and the last node of that graph. The first node will be connected to the audio source and the last node will be connected to the destination of the AudioContext (e.g. speakers). Requires Web Audio API support.
Static
EVENT_Fired when the sound currently played by the instance ends.
Static
EVENT_Fired when the instance is paused.
Static
EVENT_Fired when the instance starts playing its source.
Static
EVENT_Fired when the instance is resumed.
Static
EVENT_Fired when the instance is stopped.
A SoundInstance3d plays a Sound in 3D.