Phaser API Documentation

  Version: 
Filter
Namespace: Sound
Phaser.Types.Sound

Type Definitions

AudioSpriteSound
Focus
Focus

Description:

Audio sprite sound type.

Properties:
name type description
spritemap object

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

Type:
object
Since: 3.0.0
Focus
Focus
DecodeAudioConfig
Focus
Focus

Description:

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.

Properties:
name type description
key string

The string-based key to be used to reference the decoded audio in the audio cache.

data ArrayBuffer | string

The audio data, either a base64 encoded string, an audio media-type data uri, or an ArrayBuffer instance.

Type:
object
Since: 3.18.0
Focus
Focus
EachActiveSoundCallback(manager, sound, index, sounds)
Focus
Focus

Parameters:

name type description
manager Phaser.Sound.BaseSoundManager

The SoundManager

sound Phaser.Sound.BaseSound

The current active Sound

index number

The index of the current active Sound

sounds Array.<Phaser.Sound.BaseSound>

All sounds

Type:
function
Since: 3.0.0
Focus
Focus
SoundConfig
Focus
Focus

Description:

Config object containing various sound settings.

Properties:
name type arguments Default description
mute boolean <optional> false

Boolean indicating whether the sound should be muted or not.

volume number <optional> 1

A value between 0 (silence) and 1 (full volume).

rate number <optional> 1

Defines the speed at which the sound should be played.

detune number <optional> 0

Represents detuning of sound in cents.

seek number <optional> 0

Position of playback for this sound, in seconds.

loop boolean <optional> false

Whether or not the sound or current sound marker should loop.

delay number <optional> 0

Time, in seconds, that should elapse before the sound actually starts its playback.

pan number <optional> 0

A value between -1 (full left pan) and 1 (full right pan). 0 means no pan.

source Phaser.Types.Sound.SpatialSoundConfig <optional> null

An optional config object containing default spatial sound settings.

Type:
object
Since: 3.0.0
Focus
Focus
SoundMarker
Focus
Focus

Description:

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

Properties:
name type arguments description
name string

Unique identifier of a sound marker.

start number <optional>

Sound position offset at witch playback should start.

duration number <optional>

Playback duration of this marker.

config Phaser.Types.Sound.SoundConfig <optional>

An optional config object containing default marker settings.

Type:
object
Since: 3.0.0
Focus
Focus
SpatialSoundConfig
Focus
Focus

Description:

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

Properties:
name type arguments Default description
x number <optional> 0

The horizontal position of the audio in a right-hand Cartesian coordinate system.

y number <optional> 0

The vertical position of the audio in a right-hand Cartesian coordinate system.

z number <optional> 0

Represents the longitudinal (back and forth) position of the audio in a right-hand Cartesian coordinate system.

panningModel 'equalpower' | 'HRTF' <optional> 'equalpower'

An enumerated value determining which spatialization algorithm to use to position the audio in 3D space.

distanceModel 'linear' | 'inverse' | 'exponential' <optional> 'inverse'

Which algorithm to use to reduce the volume of the audio source as it moves away from the listener. Possible values are "linear", "inverse" and "exponential". The default value is "inverse".

orientationX number <optional> 0

The horizontal position of the audio source's vector in a right-hand Cartesian coordinate system.

orientationY number <optional> 0

The vertical position of the audio source's vector in a right-hand Cartesian coordinate system.

orientationZ number <optional> -1

Represents the longitudinal (back and forth) position of the audio source's vector in a right-hand Cartesian coordinate system.

refDistance number <optional> 1

A 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.

maxDistance number <optional> 10000

The maximum distance between the audio source and the listener, after which the volume is not reduced any further.

rolloffFactor number <optional> 1

A 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.

coneInnerAngle number <optional> 360

The angle, in degrees, of a cone inside of which there will be no volume reduction.

coneOuterAngle number <optional> 0

The angle, in degrees, of a cone outside of which the volume will be reduced by a constant value, defined by the coneOuterGain property.

coneOuterGain number <optional> 0

The 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.

follow Phaser.Types.Math.Vector2Like <optional>

Set 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
Since: 3.60.0
Focus
Focus
WebAudioDecodeEntry
Focus
Focus

Description:

An entry in the Web Audio Decoding Queue.

Properties:
name type description
key string

The key of the sound.

success function

The callback to invoke on successful decoding.

failure function

The callback to invoke if the decoding fails.

decoding boolean

Has the decoding of this sound file started?

Type:
object
Since: 3.60.0
Focus
Focus