Question regarding audio sources

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
Whatthefuck
Party member
Posts: 106
Joined: Sat Jun 21, 2014 3:45 pm

Question regarding audio sources

Post by Whatthefuck »

Hey, I have a quick question - is there a limit as to how many sounds can be played back simultaneously? I ask because it seems if I play about 30 sounds at the same time, then other sounds won't play (I call source:play(), then print(source:isPlaying()) which prints out false), and it's driving me crazy - am I doing something wrong or is there some limit set internally?
User avatar
Sir_Silver
Party member
Posts: 286
Joined: Mon Aug 22, 2016 2:25 pm
Contact:

Re: Question regarding audio sources

Post by Sir_Silver »

I am like 80% sure that there is a limit on the number of sounds you can have playing simultaneously. Not sure what that number is, or how to extend it though. I'm sure Slime or someone could have a definitive answer for you though!
Whatthefuck
Party member
Posts: 106
Joined: Sat Jun 21, 2014 3:45 pm

Re: Question regarding audio sources

Post by Whatthefuck »

I'm digging through love2d source code and have found this in src/modules/audio/openal/Pool.h:

// Maximum possible number of OpenAL sources the pool attempts to generate.
static const int MAX_SOURCES = 64;

If this is what I think it is, then there's a max. sound limit set to 64 sources.
If I could get a confirmation that it really is the limit, then I'd appreciate it.

Edit: just did a quick test from Lua side, and yep, it really is the max. source limit.
A moderator can now close the thread. :)
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Question regarding audio sources

Post by Nixola »

If I recall correctly, there are systems/situations where the number of sources can be lower than that (I seem to recall 16 playing sources as a limit).
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
slime
Solid Snayke
Posts: 3132
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Question regarding audio sources

Post by slime »

There's the max limit that love's source code imposes (64), and then there's a max limit inside the OpenAL library (i believe it's 32 or 64 on most platforms, possibly 16 on iOS? I don't remember). The actual limit will be the lower of those two, although OpenAL doesn't provide a way to query it.

You can check the return value of Source:play, it will return false if it wasn't able to play due to reaching the limit.
Post Reply

Who is online

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