Class StaticSoundAbstract
Hierarchy (View Summary)
- AbstractSound
- StaticSound
Properties
Abstract Readonlybuffer
The sound buffer that the sound uses.
This buffer can be shared with other static sounds.
Readonlyengine
The audio engine this node belongs to.
Readonlyon Dispose Observable
Observable for when the audio node is disposed.
Readonlyon Ended Observable
Observable for when the sound stops playing.
Readonlyon Name Changed Observable
{ newName: string; node: AbstractNamedAudioNode; oldName: string },
> = ...
Observable for when the audio node is renamed.
Abstractstereo
The stereo features of the sound.
Accessors
_ is Spatial
-
set _isSpatial(value: boolean): void
Parameters
- value: boolean
Returns void
active Instances Count
-
get activeInstancesCount(): number
The number of active instances of the sound that are currently playing.
Returns number
analyzer
-
The audio analyzer features.
Returns AbstractAudioAnalyzer
autoplay
-
get autoplay(): boolean
Whether the sound should start playing automatically. Defaults to
false.Returns boolean
current Time
-
get currentTime(): number
The current playback time of the sound, in seconds.
Returns number
-
set currentTime(value: number): void
Parameters
- value: number
Returns void
duration
-
get duration(): number
The amount of time to play the sound for, in seconds. Defaults to
0.- If less than or equal to
0, the sound plays for its full duration.
Returns number
- If less than or equal to
-
set duration(value: number): void
Parameters
- value: number
Returns void
loop
-
get loop(): boolean
Whether the sound should loop. Defaults to
false.Returns boolean
-
set loop(value: boolean): void
Parameters
- value: boolean
Returns void
loop End
-
get loopEnd(): number
The end of the loop range, in seconds. Defaults to
0.- If less than or equal to
0, the loop plays for the sound's full duration.
Returns number
- If less than or equal to
-
set loopEnd(value: number): void
Parameters
- value: number
Returns void
loop Start
-
get loopStart(): number
The start of the loop range, in seconds. Defaults to
0.- If less than or equal to
0, the loop starts at the beginning of the sound.
Returns number
- If less than or equal to
-
set loopStart(value: number): void
Parameters
- value: number
Returns void
max Instances
-
get maxInstances(): number
The maximum number of instances that can play at the same time. Defaults to
Infinity.Returns number
-
set maxInstances(value: number): void
Parameters
- value: number
Returns void
name
-
get name(): string
The name of the audio node.
- Triggers
onNameChangedObservablewhen changed.
Returns string
- Triggers
-
set name(newName: string): void
Parameters
- newName: string
Returns void
out Bus
-
Parameters
- outBus: Nullable<PrimaryAudioBus>
Returns void
pitch
-
get pitch(): number
The pitch of the sound, in cents. Defaults to
0.- Gets combined with playbackRate to determine the final pitch.
Returns number
-
set pitch(value: number): void
Parameters
- value: number
Returns void
playback Rate
-
get playbackRate(): number
The playback rate of the sound. Defaults to
1.- Gets combined with pitch to determine the final playback rate.
Returns number
-
set playbackRate(value: number): void
Parameters
- value: number
Returns void
spatial
-
The spatial audio features.
Returns AbstractSpatialAudio
start Offset
-
get startOffset(): number
The time within the sound buffer to start playing at, in seconds. Defaults to
0.Returns number
-
set startOffset(value: number): void
Parameters
- value: number
Returns void
state
-
The state of the sound.
Returns SoundState
volume
-
get volume(): number
The audio output volume.
Returns number
-
set volume(value: number): void
Parameters
- value: number
Returns void
Methods
Abstractclone Async
-
Clones the sound.
Parameters
Optionaloptions: Partial<IStaticSoundCloneOptions>Options for cloning the sound.
Returns Promise<StaticSound>
dispose
-
Releases associated resources.
Returns void
Abstractget Class Name
-
Gets a string identifying the name of the class
Returns string
the class's name as a string
pause
-
Pauses the sound.
Returns void
play
-
Plays the sound.
- Triggers
onEndedObservableif played for the full duration and theloopoption is not set.
Parameters
- options: Partial<IStaticSoundPlayOptions> = {}
The options to use when playing the sound. Options set here override the sound's options.
Returns void
- Triggers
resume
-
Resumes the sound.
- Only options explicitly set here override the paused instance's current options; unset options keep their paused values so playback continues from where it was paused.
Parameters
Optionaloptions: Partial<IStaticSoundPlayOptions>The options to use when resuming the sound.
Returns void
set Volume
-
Sets the audio output volume with optional ramping. If the duration is 0 then the volume is set immediately, otherwise it is ramped to the new value over the given duration using the given shape. If a ramp is already in progress then the volume is not set and an error is thrown.
Parameters
- value: number
The value to set the volume to.
- options: Nullable<Partial<IAudioParameterRampOptions>> = null
The options to use for ramping the volume change.
Returns void
- value: number
stop
-
Stops the sound.
- Triggers
onEndedObservableif the sound is playing.
Parameters
- options: Partial<IStaticSoundStopOptions> = {}
The options to use when stopping the sound.
Returns void
- Triggers
Abstract class representing a static sound.
A static sound has a sound buffer that is loaded into memory all at once. This allows it to have more capabilities than a streaming sound, such as loop points and playback rate changes, but it also means that the sound must be fully downloaded and decoded before it can be played, which may take a long time for sounds with long durations.
To prevent downloading and decoding a sound multiple times, a sound's buffer can be shared with other sounds. See CreateSoundBufferAsync, StaticSoundBuffer and StaticSound.buffer for more information.
Static sounds are created by the CreateSoundAsync function.