Difference between revisions of "love.audio.newSource"
(reflect changes in love 11.0) |
m (→Notes: missing ]) |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 4: | Line 4: | ||
== Function == | == Function == | ||
− | {{newin|[[ | + | {{newin|[[11.0]]|110|type=variant}} |
=== Synopsis === | === Synopsis === | ||
<source lang="lua"> | <source lang="lua"> | ||
Line 16: | Line 16: | ||
== Function == | == Function == | ||
− | {{newin|[[ | + | {{newin|[[11.0]]|110|type=variant}} |
=== Synopsis === | === Synopsis === | ||
<source lang="lua"> | <source lang="lua"> | ||
Line 28: | Line 28: | ||
== Function == | == Function == | ||
− | {{newin|[[ | + | {{newin|[[11.0]]|110|type=variant}} |
=== Synopsis === | === Synopsis === | ||
<source lang="lua"> | <source lang="lua"> | ||
Line 40: | Line 40: | ||
== Function == | == Function == | ||
− | {{newin|[[ | + | {{newin|[[11.0]]|110|type=variant}} |
=== Synopsis === | === Synopsis === | ||
<source lang="lua"> | <source lang="lua"> | ||
Line 62: | Line 62: | ||
== Function == | == Function == | ||
− | {{oldin|[[ | + | {{oldin|[[11.0]]|110|type=variant}} |
=== Synopsis === | === Synopsis === | ||
<source lang="lua"> | <source lang="lua"> | ||
Line 74: | Line 74: | ||
== Function == | == Function == | ||
− | {{oldin|[[ | + | {{oldin|[[11.0]]|110|type=variant}} |
=== Synopsis === | === Synopsis === | ||
<source lang="lua"> | <source lang="lua"> | ||
Line 86: | Line 86: | ||
== Function == | == Function == | ||
− | {{oldin|[[ | + | {{oldin|[[11.0]]|110|type=variant}} |
=== Synopsis === | === Synopsis === | ||
<source lang="lua"> | <source lang="lua"> | ||
Line 98: | Line 98: | ||
== Function == | == Function == | ||
− | {{oldin|[[ | + | {{oldin|[[11.0]]|110|type=variant}} |
=== Synopsis === | === Synopsis === | ||
<source lang="lua"> | <source lang="lua"> | ||
Line 108: | Line 108: | ||
=== Returns === | === Returns === | ||
{{param|Source|source|A new Source that can play the specified audio.}} | {{param|Source|source|A new Source that can play the specified audio.}} | ||
+ | |||
+ | == Notes == | ||
+ | From [[11.0]] to [[11.2]], if '''queue''' is specified as [[SourceType]] for this specific constructor, it won't error, and getType will return '''stream'''; one should use [[love.audio.newQueueableSource]] for that specific source type instead. This was a bug fixed in [[11.3]]. | ||
== Examples == | == Examples == |
Latest revision as of 13:15, 13 February 2022
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! |
Contents
Function
Available since LÖVE 11.0 |
This variant is not supported in earlier versions. |
Synopsis
source = love.audio.newSource( filename, type )
Arguments
string filename
- The filepath to the audio file.
SourceType type
- Streaming or static source.
Returns
Source source
- A new Source that can play the specified audio.
Function
Available since LÖVE 11.0 |
This variant is not supported in earlier versions. |
Synopsis
source = love.audio.newSource( file, type )
Arguments
File file
- A File pointing to an audio file.
SourceType type
- Streaming or static source.
Returns
Source source
- A new Source that can play the specified audio.
Function
Available since LÖVE 11.0 |
This variant is not supported in earlier versions. |
Synopsis
source = love.audio.newSource( decoder, type )
Arguments
Decoder decoder
- The Decoder to create a Source from.
SourceType type
- Streaming or static source.
Returns
Source source
- A new Source that can play the specified audio.
Function
Available since LÖVE 11.0 |
This variant is not supported in earlier versions. |
Synopsis
source = love.audio.newSource( data, type )
Arguments
FileData data
- The FileData to create a Source from.
SourceType type
- Streaming or static source.
Returns
Source source
- A new Source that can play the specified audio.
Function
Synopsis
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
Removed in LÖVE 11.0 |
This variant is not supported in that and later versions. |
Synopsis
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
Removed in LÖVE 11.0 |
This variant is not supported in that and later versions. |
Synopsis
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
Removed in LÖVE 11.0 |
This variant is not supported in that and later versions. |
Synopsis
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
Removed in LÖVE 11.0 |
This variant is not supported in that and later versions. |
Synopsis
source = love.audio.newSource( data, type )
Arguments
FileData data
- The FileData to create a Source from.
SourceType type ("stream")
- Streaming or static source.
Returns
Source source
- A new Source that can play the specified audio.
Notes
From 11.0 to 11.2, if queue is specified as SourceType for this specific constructor, it won't error, and getType will return stream; one should use love.audio.newQueueableSource for that specific source type instead. This was a bug fixed in 11.3.
Examples
Load background music and play it
bgm = love.audio.newSource("bgm.ogg", "stream")
love.audio.play(bgm)
Load a sound effect and play it
sfx = love.audio.newSource("sfx.wav", "static")
love.audio.play(sfx)
Load SoundData and create a Source
data = love.sound.newSoundData("sfx.wav")
sfx = love.audio.newSource(data)
Load Decoder and create a Source
decoder = love.sound.newDecoder("bgm.ogg")
bgm = love.audio.newSource(decoder, "stream")
See Also
Other Languages
Dansk –
Deutsch –
English –
Español –
Français –
Indonesia –
Italiano –
Lietuviškai –
Magyar –
Nederlands –
Polski –
Português –
Română –
Slovenský –
Suomi –
Svenska –
Türkçe –
Česky –
Ελληνικά –
Български –
Русский –
Српски –
Українська –
עברית –
ไทย –
日本語 –
正體中文 –
简体中文 –
Tiếng Việt –
한국어
More info