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 » Tue Jul 15, 2014 1:09 pm

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: 4944
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Difference between streaming and static audio?

Post by bartbes » Tue Jul 15, 2014 1:50 pm


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 » Tue Jul 15, 2014 1:56 pm

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 » Tue Jul 15, 2014 2:40 pm

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: 2820
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Difference between streaming and static audio?

Post by slime » Tue Jul 15, 2014 3:28 pm

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: Exabot [Bot], master both, Schwender.exe and 7 guests