Skip to main content

updateSound()

world.audio.updateSound(eid, newAudio)

Description

Update sound of an entity.

Parameters

PropertyTypeDescription
eidEidThe eid of the Sound.
newAudioAudioSettingsAudio settings.

AudioSettings

type AudioSettings = {url, volume, loop, pitch, paused, positional, refDistance, rolloffFactor, distanceModel, maxDistance}
PropertyTypeDefaultDescription
urlstring-The source url.
volume (optional)number1How loud the audio will be played. A value between 0 and 1.
loop (optional)booleanfalseWhether the audio restarts after it finishes playing or not.
paused (optional)booleanfalseWhether the audio is paused or currently playing.
pitch (optional)number1The factor used to change the audio's pitch, with 1.0 being the audio's default, 2.0 being one octave higher, 0.5 one octave lower, etc.
positional (optional)booleanfalseWhether the audio is positional (considers position relative to the listener) or not.
refDistance (optional)number1Only applied if positional is true. The value indicating at what distance the volume from this source will start reducing as the listener moves away. Must be a non-negative value.
distanceModel (optional)stringinverseOnly applied if positional is true. The algorithm used to reduce volume as the distance increases between this audio source and the listener. Possible values include linear, inverse, and exponential.
rolloffFactor (optional)number1Only applied if positional is true. How quickly volume is reduced as distance increases between this audio source and the listener. The acceptable range of values changes depending on the distanceModel, shown by the following: linear: 0 to 1, inverse: 0 to Infinity, exponential: 0 to Infinity
maxDistance (optional)number10000Only applied if positional is true and distanceModel equals linear. The max distance between this audio source and the listener. Volume is not reduced after this point. Must be a positive value.

Returns

None.