Creates a new Source from an ogg, wav, or mp3 file.
Arguments
Name
Type
Default
Description
filename
string
The filename of the sound to load.
options
table
Optional options.
.decode
boolean
false
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.
.pitchable
boolean
true
Whether the pitch of the Source can be changed with Source:setPitch. Setting this to false will improve performance slightly.
.spatial
boolean
true
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.
.effects
table
nil
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.
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.
.pitchable
boolean
true
Whether the pitch of the Source can be changed with Source:setPitch. Setting this to false will improve performance slightly.
.spatial
boolean
true
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.
.effects
table
nil
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.
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.
.pitchable
boolean
true
Whether the pitch of the Source can be changed with Source:setPitch. Setting this to false will improve performance slightly.
.spatial
boolean
true
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.
.effects
table
nil
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.