Page 1 of 1

Sound Pool (manager)

Posted: Sat Jul 11, 2020 8:30 am
by AlexYeCu
Does anyone know a lib or a method for love 2d to organize sound pool?
For example, we need to play one sound several times. And next playing should start before this sound ends.
So, after checking playing status, we can start stopped sound again or, if it still playing, create a copy of it's source and start to play the copy. The quantity of copies is limited, so if we are out of limit, the stop last sound in a pool and start it from initial position.

Re: Sound Pool (manager)

Posted: Sat Jul 11, 2020 10:18 am
by Nikki
Not a pool implementation, but are you aware you can use clone() on the Source ?
that way you can play the same sound many times

https://love2d.org/wiki/Source:clone

Re: Sound Pool (manager)

Posted: Sat Jul 11, 2020 2:48 pm
by AlexYeCu
Well, as I understand, I should then manually remove all clones?

Re: Sound Pool (manager)

Posted: Sat Jul 11, 2020 5:33 pm
by zorg
You could put all clones in a table with the original one, and you can check which of them finished in a loop, and if you found one, call play on that, otherwise clone another one; you could make a tiny lib to do this too if you wanted to; alternatively there are a few libs that support these but i dont use them myself.

Re: Sound Pool (manager)

Posted: Sat Jul 11, 2020 6:46 pm
by AlexYeCu
zorg, you've described how the SoundPool should work. I know this, but I do not want to do it myself if someone did it before.

>alternatively there are a few libs

What libs? I've found noone.

Re: Sound Pool (manager)

Posted: Sun Jul 12, 2020 7:47 am
by zorg
https://github.com/drhayes/TESound - Apparently this creates new Source objects each time you call it... not the best implementation and i never recommend it, but i will mention it at the very least.
https://github.com/Ulydev/wave - A decent lib, but very specific; it does support instances but the implementation's a bit complicated.

I'd go with https://github.com/tesselode/ripple since it has a very neatly designed API, and also supports tons of features, instancing and tagging as well. (not to mention that this one does implement pooling how i explained it previously :3)

However if you just want pooling, and not the other stuff, it's faster to just implement it yourself. :P