Difference between streaming and static audio?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
parallax7d
Citizen
Posts: 82
Joined: Wed Jul 02, 2014 11:44 pm

Difference between streaming and static audio?

Post 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)
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Difference between streaming and static audio?

Post by bartbes »

User avatar
rmcode
Party member
Posts: 454
Joined: Tue Jul 15, 2014 12:04 pm
Location: Germany
Contact:

Re: Difference between streaming and static audio?

Post 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
User avatar
parallax7d
Citizen
Posts: 82
Joined: Wed Jul 02, 2014 11:44 pm

Re: Difference between streaming and static audio?

Post 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
User avatar
slime
Solid Snayke
Posts: 3132
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Difference between streaming and static audio?

Post 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.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 30 guests