lovr.audio.newSource

Edit

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




Arguments

NameTypeDefaultDescription
filestring | Blob A filename or Blob containing audio data to load.
optionstablenil 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.
.spatialbooleanfalse Whether the Source should use spatial effects. Non-spatial sources will get routed directly to the speakers without further processing.
.pitchablebooleantrue Whether the pitch of the Source can be changed with Source:setPitch. Setting this to false will improve performance slightly.

Returns

NameTypeDescription
sourceSource The new Source.

Arguments

NameTypeDefaultDescription
soundSound The Sound containing audio to play.
optionstablenil 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.
.spatialbooleanfalse Whether the Source should use spatial effects. Non-spatial sources will get routed directly to the speakers without further processing.
.pitchablebooleantrue Whether the pitch of the Source can be changed with Source:setPitch. Setting this to false will improve performance slightly.

Returns

NameTypeDescription
sourceSource The new Source.

Arguments

NameTypeDefaultDescription
streamSound The AudioStream containing audio to play.
optionstablenil 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.
.spatialbooleanfalse Whether the Source should use spatial effects. Non-spatial sources will get routed directly to the speakers without further processing.
.pitchablebooleantrue Whether the pitch of the Source can be changed with Source:setPitch. Setting this to false will improve performance slightly.

Returns

NameTypeDescription
sourceSource The new Source.

Example

function lovr.load()
  sandstorm = lovr.audio.newSource('darude.ogg', { decode = false })
  sandstorm:play()
end

See also