Page 1 of 1

Difference between streaming and static audio?

Posted: Tue Jul 15, 2014 1:09 pm
by parallax7d
What is the distinction between streaming and static audio? Are they different channels?

Load background music and play it

Code: Select all

bgm = love.audio.newSource("bgm.ogg", "stream")
love.audio.play(bgm)
Load a sound effect and play it

Code: Select all

sfx = love.audio.newSource("sfx.wav", "static")
love.audio.play(sfx)

Re: Difference between streaming and static audio?

Posted: Tue Jul 15, 2014 1:50 pm
by bartbes

Re: Difference between streaming and static audio?

Posted: Tue Jul 15, 2014 1:56 pm
by rmcode
I also wondered this a while ago and found this explanation (IMO the one bartbes linked is a bit cryptic):
Keep in mind that, if you pass love.audio.newSource "static" as a second argument, the sound file will be expanded into memory, so if you load a 5MB compressed .ogg file that way, it would consume ~50MB RAM when fully decompressed. Consider not using "static" in such cases.

If you omit the "static", the audio will be streamed from the file as it's played, something that saves a lot of memory when you're dealing with massive files.
- http://love2d.org/wiki/Tutorial:Audio

Re: Difference between streaming and static audio?

Posted: Tue Jul 15, 2014 2:40 pm
by parallax7d
Thanks bartbes, I'll have to search harder next time! I like how all the docs are on the wiki, makes it very easy to search.

rmcode, that's really good to know, thanks

Re: Difference between streaming and static audio?

Posted: Tue Jul 15, 2014 3:28 pm
by slime
In general you should use 'stream' for music and 'static' for everything else (audio clips.) Streaming Sources will be decoded every time each Source is played, whereas static Sources will be decoded only once when they're loaded.

You can also use [wiki]Source:clone[/wiki] with static Sources to have multiple Sources which play the same audio without taking up more RAM, but you won't get that benefit if you use it on streaming Sources.