Skip to main content
Version: Phaser v3.88.2

Types.Sound

AudioSpriteSound

<static> AudioSpriteSound

Audio sprite sound type.

nametypeoptionaldescription
spritemapobjectNoLocal reference to 'spritemap' object form json file generated by audiosprite tool.

Type: object

Member of: Phaser.Types.Sound

Source: src/sound/typedefs/AudioSpriteSound.js#L1
Since: 3.0.0


DecodeAudioConfig

<static> DecodeAudioConfig

A Audio Data object.

You can pass an array of these objects to the WebAudioSoundManager decodeAudio method to have it decode

them all at once.

nametypeoptionaldescription
keystringNoThe string-based key to be used to reference the decoded audio in the audio cache.
dataArrayBuffer | stringNoThe audio data, either a base64 encoded string, an audio media-type data uri, or an ArrayBuffer instance.

Type: object

Member of: Phaser.Types.Sound

Source: src/sound/typedefs/DecodeAudioConfig.js#L1
Since: 3.18.0


EachActiveSoundCallback

<static> EachActiveSoundCallback

Type: function

Member of: Phaser.Types.Sound

Source: src/sound/typedefs/EachActiveSoundCallback.js#L1
Since: 3.0.0


SoundConfig

<static> SoundConfig

Config object containing various sound settings.

nametypeoptionaldefaultdescription
mutebooleanYesfalseBoolean indicating whether the sound should be muted or not.
volumenumberYes1A value between 0 (silence) and 1 (full volume).
ratenumberYes1Defines the speed at which the sound should be played.
detunenumberYes0Represents detuning of sound in cents.
seeknumberYes0Position of playback for this sound, in seconds.
loopbooleanYesfalseWhether or not the sound or current sound marker should loop.
delaynumberYes0Time, in seconds, that should elapse before the sound actually starts its playback.
pannumberYes0A value between -1 (full left pan) and 1 (full right pan). 0 means no pan.
sourcePhaser.Types.Sound.SpatialSoundConfigYesnullAn optional config object containing default spatial sound settings.

Type: object

Member of: Phaser.Types.Sound

Source: src/sound/typedefs/SoundConfig.js#L1
Since: 3.0.0


SoundMarker

<static> SoundMarker

Marked section of a sound represented by name, and optionally start time, duration, and config object.

nametypeoptionaldefaultdescription
namestringNoUnique identifier of a sound marker.
startnumberYes0Sound position offset at witch playback should start.
durationnumberYesPlayback duration of this marker.
configPhaser.Types.Sound.SoundConfigYesAn optional config object containing default marker settings.

Type: object

Member of: Phaser.Types.Sound

Source: src/sound/typedefs/SoundMarker.js#L1
Since: 3.0.0


SpatialSoundConfig

<static> SpatialSoundConfig

Config object containing settings for the source of the spatial sound.

See https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Web_audio_spatialization_basics

nametypeoptionaldefaultdescription
xnumberYes0The horizontal position of the audio in a right-hand Cartesian coordinate system.
ynumberYes0The vertical position of the audio in a right-hand Cartesian coordinate system.
znumberYes0Represents the longitudinal (back and forth) position of the audio in a right-hand Cartesian coordinate system.
panningModel'equalpower' | 'HRTF'Yes"'equalpower'"An enumerated value determining which spatialization algorithm to use to position the audio in 3D space.
distanceModel'linear' | 'inverse''exponential'Yes"'inverse'"
orientationXnumberYes0The horizontal position of the audio source's vector in a right-hand Cartesian coordinate system.
orientationYnumberYes0The vertical position of the audio source's vector in a right-hand Cartesian coordinate system.
orientationZnumberYes-1Represents the longitudinal (back and forth) position of the audio source's vector in a right-hand Cartesian coordinate system.
refDistancenumberYes1A double value representing the reference distance for reducing volume as the audio source moves further from the listener. For distances greater than this the volume will be reduced based on rolloffFactor and distanceModel.
maxDistancenumberYes10000The maximum distance between the audio source and the listener, after which the volume is not reduced any further.
rolloffFactornumberYes1A double value describing how quickly the volume is reduced as the source moves away from the listener. This value is used by all distance models.
coneInnerAnglenumberYes360The angle, in degrees, of a cone inside of which there will be no volume reduction.
coneOuterAnglenumberYes0The angle, in degrees, of a cone outside of which the volume will be reduced by a constant value, defined by the coneOuterGain property.
coneOuterGainnumberYes0The amount of volume reduction outside the cone defined by the coneOuterAngle attribute. Its default value is 0, meaning that no sound can be heard. A value between 0 and 1.
followPhaser.Types.Math.Vector2LikeYesSet this Sound object to automatically track the x/y position of this object. Can be a Phaser Game Object, Vec2 or anything that exposes public x/y properties.

Type: object

Member of: Phaser.Types.Sound

Source: src/sound/typedefs/SpatialSoundConfig.js#L1
Since: 3.60.0


WebAudioDecodeEntry

<static> WebAudioDecodeEntry

An entry in the Web Audio Decoding Queue.

nametypeoptionaldescription
keystringNoThe key of the sound.
successfunctionNoThe callback to invoke on successful decoding.
failurefunctionNoThe callback to invoke if the decoding fails.
decodingbooleanNoHas the decoding of this sound file started?

Type: object

Member of: Phaser.Types.Sound

Source: src/sound/typedefs/WebAudioDecodeEntry.js#L1
Since: 3.60.0