lovr.audio.newSource

Edit

Creates a new Source from an ogg, wav, or mp3 file.




Arguments

NameTypeDefaultDescription
filenamestring The filename of the sound to load.
optionstable Optional options.
.decodebooleanfalse Whether to immediately decode compressed sounds, instead of progressively decoding as the Source plays. Enabling this will use more memory but reduce CPU overhead during playback. Recommended for short sound effects.
.pitchablebooleantrue Whether the pitch of the Source can be changed with Source:setPitch. Setting this to false will improve performance slightly.
.spatialbooleantrue Whether the Source should use spatial effects. Non-spatial sources will get routed directly to the speakers without further processing. Enabling an effect on a non-spatial source will raise an error.
.effectstablenil A table of Effects to enable on the Source. This can be a list (numeric keys, effect name values) or a map (effect name keys, boolean values) or a mix of the two. Effects can also be enabled later using Source:setEffectEnabled. If nil, all effects will be enabled. Ignored if the spatial flag is false.

Returns

NameTypeDescription
sourceSource The new Source.

Arguments

NameTypeDefaultDescription
blobBlob The Blob containing the Source data.
optionstable Optional options.
.decodebooleanfalse Whether to immediately decode compressed sounds, instead of progressively decoding as the Source plays. Enabling this will use more memory but reduce CPU overhead during playback. Recommended for short sound effects.
.pitchablebooleantrue Whether the pitch of the Source can be changed with Source:setPitch. Setting this to false will improve performance slightly.
.spatialbooleantrue Whether the Source should use spatial effects. Non-spatial sources will get routed directly to the speakers without further processing. Enabling an effect on a non-spatial source will raise an error.
.effectstablenil A table of Effects to enable on the Source. This can be a list (numeric keys, effect name values) or a map (effect name keys, boolean values) or a mix of the two. Effects can also be enabled later using Source:setEffectEnabled. If nil, all effects will be enabled. Ignored if the spatial flag is false.

Returns

NameTypeDescription
sourceSource The new Source.

Arguments

NameTypeDefaultDescription
soundSound The Sound containing raw audio samples to play.
optionstable Optional options.
.decodebooleanfalse Whether to immediately decode compressed sounds, instead of progressively decoding as the Source plays. Enabling this will use more memory but reduce CPU overhead during playback. Recommended for short sound effects.
.pitchablebooleantrue Whether the pitch of the Source can be changed with Source:setPitch. Setting this to false will improve performance slightly.
.spatialbooleantrue Whether the Source should use spatial effects. Non-spatial sources will get routed directly to the speakers without further processing. Enabling an effect on a non-spatial source will raise an error.
.effectstablenil A table of Effects to enable on the Source. This can be a list (numeric keys, effect name values) or a map (effect name keys, boolean values) or a mix of the two. Effects can also be enabled later using Source:setEffectEnabled. If nil, all effects will be enabled. Ignored if the spatial flag is false.

Returns

NameTypeDescription
sourceSource The new Source.

Example

function lovr.load()
  sandstorm = lovr.audio.newSource('darude.ogg', {
    decode = false,
    effects = { 'spatialization', attenuation = false, reverb = true }
  })

  sandstorm:play()
end

See also