Difference between revisions of "love.sound.newSoundData"
(Added default values and consistency.) |
|||
Line 1: | Line 1: | ||
− | Creates new SoundData from a Decoder. | + | Creates new SoundData from a [[Decoder]] or file. It's also possible to create an empty SoundData with a custom sample rate, channel and bit depth. |
− | + | ||
+ | The sound data will be decoded to the memory in a raw format. It is recommended to create only short sounds like effects, as a 3 minute song uses 30 MB of memory this way. | ||
== Function == | == Function == | ||
=== Synopsis === | === Synopsis === | ||
<source lang="lua"> | <source lang="lua"> | ||
− | + | soundData = love.sound.newSoundData( decoder ) | |
</source> | </source> | ||
=== Arguments === | === Arguments === | ||
{{param|Decoder|decoder|Decode data from this Decoder until EOF.}} | {{param|Decoder|decoder|Decode data from this Decoder until EOF.}} | ||
=== Returns === | === Returns === | ||
− | {{param|SoundData| | + | {{param|SoundData|soundData|A new SoundData object.}} |
== Function == | == Function == | ||
=== Synopsis === | === Synopsis === | ||
<source lang="lua"> | <source lang="lua"> | ||
− | + | soundData = love.sound.newSoundData( fileName ) | |
</source> | </source> | ||
=== Arguments === | === Arguments === | ||
− | {{param|string| | + | {{param|string|fileName|The file name of the file to load.}} |
=== Returns === | === Returns === | ||
− | {{param|SoundData| | + | {{param|SoundData|soundData|A new SoundData object.}} |
== Function == | == Function == | ||
=== Synopsis === | === Synopsis === | ||
<source lang="lua"> | <source lang="lua"> | ||
− | + | soundData = love.sound.newSoundData( samples, rate, bits, channels ) | |
</source> | </source> | ||
=== Arguments === | === Arguments === | ||
{{param|number|samples|Total number of samples.}} | {{param|number|samples|Total number of samples.}} | ||
− | {{param|number|rate|Number of samples per second}} | + | {{param|number|rate (44100)|Number of samples per second}} |
− | {{param|number|bits|Bits per sample (8 or 16).}} | + | {{param|number|bits (16)|Bits per sample (8 or 16).}} |
− | {{param|number|channels|Either 1 for mono | + | {{param|number|channels (2)|Either 1 for mono or 2 for stereo.}} |
=== Returns === | === Returns === | ||
− | {{param|SoundData| | + | {{param|SoundData|soundData|A new SoundData object.}} |
== Examples == | == Examples == | ||
=== Loading SoundData from files === | === Loading SoundData from files === |
Revision as of 09:49, 15 June 2011
Creates new SoundData from a Decoder or file. It's also possible to create an empty SoundData with a custom sample rate, channel and bit depth.
The sound data will be decoded to the memory in a raw format. It is recommended to create only short sounds like effects, as a 3 minute song uses 30 MB of memory this way.
Contents
Function
Synopsis
soundData = love.sound.newSoundData( decoder )
Arguments
Decoder decoder
- Decode data from this Decoder until EOF.
Returns
SoundData soundData
- A new SoundData object.
Function
Synopsis
soundData = love.sound.newSoundData( fileName )
Arguments
string fileName
- The file name of the file to load.
Returns
SoundData soundData
- A new SoundData object.
Function
Synopsis
soundData = love.sound.newSoundData( samples, rate, bits, channels )
Arguments
number samples
- Total number of samples.
number rate (44100)
- Number of samples per second
number bits (16)
- Bits per sample (8 or 16).
number channels (2)
- Either 1 for mono or 2 for stereo.
Returns
SoundData soundData
- A new SoundData object.
Examples
Loading SoundData from files
wav = love.sound.newSoundData("doom.wav")
-- Beware: if doom.mp3 is a huge file, it will take
-- ages to decode.
mp3 = love.sound.newSoundData("doom.mp3")
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