Creates a new [[Source]] from a filepath, [[File]], [[Decoder]] or [[SoundData]].
Sources created from SoundData are always static.
{{newobjectnotice}}

== Function ==
{{newin|[[11.0]]|110|type=variant}}
=== Synopsis ===
<source lang="lua">
source = love.audio.newSource( filename, type )
</source>
=== Arguments ===
{{param|string|filename|The filepath to the audio file.}}
{{param|SourceType|type|Streaming or static source.}}
=== Returns ===
{{param|Source|source|A new Source that can play the specified audio.}}

== Function ==
{{newin|[[11.0]]|110|type=variant}}
=== Synopsis ===
<source lang="lua">
source = love.audio.newSource( file, type )
</source>
=== Arguments ===
{{param|File|file|A File pointing to an audio file.}}
{{param|SourceType|type|Streaming or static source.}}
=== Returns ===
{{param|Source|source|A new Source that can play the specified audio.}}

== Function ==
{{newin|[[11.0]]|110|type=variant}}
=== Synopsis ===
<source lang="lua">
source = love.audio.newSource( decoder, type )
</source>
=== Arguments ===
{{param|Decoder|decoder|The Decoder to create a Source from.}}
{{param|SourceType|type|Streaming or static source.}}
=== Returns ===
{{param|Source|source|A new Source that can play the specified audio.}}

== Function ==
{{newin|[[11.0]]|110|type=variant}}
=== Synopsis ===
<source lang="lua">
source = love.audio.newSource( data, type )
</source>
=== Arguments ===
{{param|FileData|data|The FileData to create a Source from.}}
{{param|SourceType|type|Streaming or static source.}}
=== Returns ===
{{param|Source|source|A new Source that can play the specified audio.}}

== Function ==
=== Synopsis ===
<source lang="lua">
source = love.audio.newSource( data )
</source>
=== Arguments ===
{{param|SoundData|data|The SoundData to create a Source from.}}
=== Returns ===
{{param|Source|source|A new Source that can play the specified audio. The [[SourceType]] of the returned audio is "static".}}

== Function ==
{{oldin|[[11.0]]|110|type=variant}}
=== Synopsis ===
<source lang="lua">
source = love.audio.newSource( filename, type )
</source>
=== Arguments ===
{{param|string|filename|The filepath to the audio file.}}
{{param|SourceType|type ("stream")|Streaming or static source.}}
=== Returns ===
{{param|Source|source|A new Source that can play the specified audio.}}

== Function ==
{{oldin|[[11.0]]|110|type=variant}}
=== Synopsis ===
<source lang="lua">
source = love.audio.newSource( file, type )
</source>
=== Arguments ===
{{param|File|file|A File pointing to an audio file.}}
{{param|SourceType|type ("stream")|Streaming or static source.}}
=== Returns ===
{{param|Source|source|A new Source that can play the specified audio.}}

== Function ==
{{oldin|[[11.0]]|110|type=variant}}
=== Synopsis ===
<source lang="lua">
source = love.audio.newSource( decoder, type )
</source>
=== Arguments ===
{{param|Decoder|decoder|The Decoder to create a Source from.}}
{{param|SourceType|type ("stream")|Streaming or static source.}}
=== Returns ===
{{param|Source|source|A new Source that can play the specified audio.}}

== Function ==
{{oldin|[[11.0]]|110|type=variant}}
=== Synopsis ===
<source lang="lua">
source = love.audio.newSource( data, type )
</source>
=== Arguments ===
{{param|FileData|data|The FileData to create a Source from.}}
{{param|SourceType|type ("stream")|Streaming or static source.}}
=== Returns ===
{{param|Source|source|A new Source that can play the specified audio.}}

== Notes ==
From [[11.0]] onwards, if '''queue''' is specified as [[SourceType]] for this specific constructor, it won't error, and getType will return '''stream'''; this is a bug. One should use [[love.audio.newQueueableSource]] for that specific source type instead.

== Examples ==
=== Load background music and play it ===
<source lang="lua">
bgm = love.audio.newSource("bgm.ogg", "stream")
love.audio.play(bgm)
</source>
=== Load a sound effect and play it ===
<source lang="lua">
sfx = love.audio.newSource("sfx.wav", "static")
love.audio.play(sfx)
</source>
=== Load SoundData and create a Source ===
<source lang="lua">
data = love.sound.newSoundData("sfx.wav")
sfx = love.audio.newSource(data)
</source>
=== Load Decoder and create a Source ===
<source lang="lua">
decoder = love.sound.newDecoder("bgm.ogg")
bgm = love.audio.newSource(decoder, "stream")
</source>
== See Also ==
* [[parent::love.audio]]
* [[Constructs::Source]]
[[Category:Functions]]
{{#set:Description=Creates a new [[Source]] from a file, [[SoundData]], or [[Decoder]].
}}
{{#set:Since=000}}
== Other Languages ==
{{i18n|love.audio.newSource}}