Skip to main content

Audio

Description:

  A record of an audio player singleton object.

soundSpeed

Type: Field.

Description:

  The speed of the sound.

Signature:

soundSpeed: number

globalVolume

Type: Field.

Description:

  The global volume.

Signature:

globalVolume: number

listener

Type: Field.

Description:

  The listener node of the 3D sound source.

Signature:

listener: Node

play

Type: Function.

Description:

  Plays a sound effect and returns a handler for the audio.

Signature:

play: function(
self: Audio,
filename: string,
loop?: boolean --[[false]]
): integer

Parameters:

ParameterTypeDescription
filenamestringThe path to the sound effect file (must be a WAV file).
loopboolean[optional] Whether to loop the sound effect (default is false).

Returns:

Return TypeDescription
integerA handler for the audio that can be used to stop the sound effect.

stop

Type: Function.

Description:

  Stops a sound effect that is currently playing.

Signature:

stop: function(self: Audio, handler: integer)

Parameters:

ParameterTypeDescription
handlerintegerThe handler for the audio that is returned by the play function.

playStream

Type: Function.

Description:

  Plays a streaming audio file.

Signature:

playStream: function(
self: Audio,
filename: string,
loop?: boolean --[[false]],
crossFadeTime?: number --[[0.0]]
)

Parameters:

ParameterTypeDescription
filenamestringThe path to the streaming audio file (can be OGG, WAV, MP3, or FLAC).
loopboolean[optional] Whether to loop the streaming audio (default is false).
crossFadeTimenumber[optional] The time (in seconds) to crossfade between the previous and new streaming audio (default is 0.0).

stopStream

Type: Function.

Description:

  Stops a streaming audio file that is currently playing.

Signature:

stopStream: function(
self: Audio,
fadeTime?: number --[[0.0]]
)

Parameters:

ParameterTypeDescription
fadeTimenumber[optional] The time (in seconds) to fade out the streaming audio (default is 0.0).

setPauseAllCurrent

Type: Function.

Description:

  Pauses all currently playing audio.

Signature:

setPauseAllCurrent: function(self: Audio, pause: boolean)

Parameters:

ParameterTypeDescription
pausebooleanThe pause state.

setListenerAt

Type: Function.

Description:

  Sets the position of the listener.

Signature:

setListenerAt: function(self: Audio, atX: number, atY: number, atZ: number)

Parameters:

ParameterTypeDescription
atXnumberThe x-axis position.
atYnumberThe y-axis position.
atZnumberThe z-axis position.

setListenerUp

Type: Function.

Description:

  Sets the up direction of the listener.

Signature:

setListenerUp: function(self: Audio, upX: number, upY: number, upZ: number)

Parameters:

ParameterTypeDescription
upXnumberThe x-axis up direction.
upYnumberThe y-axis up direction.
upZnumberThe z-axis up direction.

setListenerVelocity

Type: Function.

Description:

  Sets the velocity of the listener.

Signature:

setListenerVelocity: function(self: Audio, velocityX: number, velocityY: number, velocityZ: number)

Parameters:

ParameterTypeDescription
velocityXnumberThe x-axis velocity.
velocityYnumberThe y-axis velocity.
velocityZnumberThe z-axis velocity.