Skip to main content

AudioSource

Description:

  A record that represents an audio source.

Class Object: AudioSource Class.

Inherits from: Node.

AudioSource.AttenuationModel

Type: Enumeration.

Description:

  The model of the attenuation.

Signature:

enum AttenuationModel
"NoAttenuation"
"InverseDistance"
"LinearDistance"
"ExponentialDistance"
end

volume

Type: Field.

Description:

  The volume of the audio source. The value is between 0.0 and 1.0.

Signature:

volume: number

pan

Type: Field.

Description:

  The pan of the audio source. The value is between -1.0 and 1.0.

Signature:

pan: number

looping

Type: Field.

Description:

  Whether the audio source is looped.

Signature:

looping: boolean

playing

Type: Field.

Description:

  Whether the audio source is playing.

Signature:

playing: boolean

seek

Type: Function.

Description:

  Seeks to the specified time in the audio source.

Signature:

seek: function(self: AudioSource, startTime: number)

Parameters:

ParameterTypeDescription
startTimenumberThe time to seek to.

scheduleStop

Type: Function.

Description:

  Schedules the stop of the audio source.

Signature:

scheduleStop: function(self: AudioSource, timeToStop: number)

Parameters:

ParameterTypeDescription
timeToStopnumberThe time to stop the audio source.

stop

Type: Function.

Description:

  Stops the audio source.

Signature:

stop: function(self: AudioSource, fadeTime?: number)

Parameters:

ParameterTypeDescription
fadeTimenumberThe time to fade the audio source. Default is 0 seconds.

play

Type: Function.

Description:

  Plays the audio source.

Signature:

play: function(self: AudioSource, delayTime?: number): boolean

Parameters:

ParameterTypeDescription
delayTimenumber[optional] The time to delay before playing the audio source. Default is 0 seconds.

Returns:

Return TypeDescription
booleanWhether the audio source was played successfully.

playBackground

Type: Function.

Description:

  Plays the audio source as a background audio.

Signature:

playBackground: function(self: AudioSource): boolean

Returns:

Return TypeDescription
booleanWhether the audio source was played successfully.

play3D

Type: Function.

Description:

  Plays the audio source as a 3D audio.

Signature:

play3D: function(self: AudioSource, delayTime?: number): boolean

Parameters:

ParameterTypeDescription
delayTimenumber[optional] The time to delay before playing the audio source. Default is 0 seconds.

Returns:

Return TypeDescription
booleanWhether the audio source was played successfully.

setProtected

Type: Function.

Description:

  Sets the protected state of the audio source. If the audio source is protected, it won't get stopped if we run out of voices.

Signature:

setProtected: function(self: AudioSource, var: boolean)

Parameters:

ParameterTypeDescription
varbooleanThe protected state to set.

setLoopPoint

Type: Function.

Description:

  Sets the loop point of the audio source. The audio source will loop from the specified time to the end of the audio.

Signature:

setLoopPoint: function(self: AudioSource, loopStartTime: number)

Parameters:

ParameterTypeDescription
loopStartTimenumberThe time to loop the audio source.

setVelocity

Type: Function.

Description:

  Sets the velocity of the 3D audio source.

Signature:

setVelocity: function(self: AudioSource, vx: number, vy: number, vz: number)

Parameters:

ParameterTypeDescription
vxnumberThe x-axis velocity.
vynumberThe y-axis velocity.
vznumberThe z-axis velocity.

setMinMaxDistance

Type: Function.

Description:

  Sets the minimum and maximum distance of the 3D audio source.

Signature:

setMinMaxDistance: function(self: AudioSource, min: number, max: number)

Parameters:

ParameterTypeDescription
minnumberThe minimum distance.
maxnumberThe maximum distance.

setAttenuation

Type: Function.

Description:

  Sets the attenuation model of the 3D audio source.

Signature:

setAttenuation: function(self: AudioSource, model: AttenuationModel, factor: number)

Parameters:

ParameterTypeDescription
modelAttenuationModelThe model of the attenuation.
factornumberThe factor of the attenuation.

setDopplerFactor

Type: Function.

Description:

  Sets the Doppler factor of the 3D audio source.

Signature:

setDopplerFactor: function(self: AudioSource, factor: number)

Parameters:

ParameterTypeDescription
factornumberThe factor of the Doppler effect.