love.audio.newSource
Creates a new Source from a filepath, File, Decoder or SoundData. Sources created from SoundData are always static.
This function can be slow if it is called repeatedly, such as from love.update or love.draw. If you need to use a specific resource often, create it once and store it somewhere it can be reused!
Function
Synopsis
1 | source = love.audio.newSource( filename, type ) |
Arguments
string filename
- The filepath to the audio file.
SourceType type ("stream")
- Streaming or static source.
Returns
Source source
- A new Source that can play the specified audio.
Function
Synopsis
1 | source = love.audio.newSource( file, type ) |
Arguments
File file
- A File pointing to an audio file.
SourceType type ("stream")
- Streaming or static source.
Returns
Source source
- A new Source that can play the specified audio.
Function
Synopsis
1 | source = love.audio.newSource( decoder, type ) |
Arguments
Decoder decoder
- The Decoder to create a Source from.
SourceType type ("stream")
- Streaming or static source.
Returns
Source source
- A new Source that can play the specified audio.
Function
Synopsis
1 | source = love.audio.newSource( data ) |
Arguments
SoundData data
- The SoundData to create a Source from.
Returns
Source source
- A new Source that can play the specified audio. The SourceType of the returned audio is "static".
Function
Synopsis
1 | source = love.audio.newSource( data ) |
Arguments
FileData data
- The FileData to create a Source from.
Returns
Source source
- A new Source that can play the specified audio.
Examples
Load background music and play it
1 2 | bgm = love.audio.newSource("bgm.ogg", "stream") love.audio.play(bgm) |
Load a sound effect and play it
1 2 | sfx = love.audio.newSource("sfx.wav", "static") love.audio.play(sfx) |
Load SoundData and create a Source
1 2 | data = love.sound.newSoundData("sfx.wav") sfx = love.audio.newSource(data) |
Load Decoder and create a Source
1 2 | decoder = love.sound.newDecoder("bgm.ogg") bgm = love.audio.newSource(decoder) |
Please login to continue.