jarikomppa / soloud

Free, easy, portable audio engine for games
http://soloud-audio.com
Other
1.76k stars 276 forks source link

Feature Request: method to empty a Queue #286

Open TwoDimensionsReturn opened 4 years ago

TwoDimensionsReturn commented 4 years ago

Hello,

I'm using SoLoud to play music cut into different pieces, that are played randomly. I'm using the Queue and it works smoothly (much easier to implement than in FMod!). When I want to play a new music, I would need to empty the Queue. Is it possible to extend the API to do so, please?

TwoDimensionsReturn commented 4 years ago

Hello @jarikomppa,

what do you advise? I'm not clear here about how to proceed? Context is I'm playing for instance a calm infinite music then if an enemy approach I would like to play a fighting infinite music. Should I try to clean the queue in between or instantiate a new one?

midn1 commented 3 years ago

What is it you have in mind exactly? Do you mean Portal 2-style music design where it's the same song playing, but additional instruments "kick in" when something is happening in the scene? Or are these random pieces completely separate?

If it's the former, you can probably play multiple music instances at once, each holding a different instrument.

TwoDimensionsReturn commented 3 years ago

Hello @midn1 ,

this is the second option, different piece of music. The exact scenario is this one:

Queue content: [calm_music_verse_6 calm_music_verse_3] I'm adding a new item in the queue among all my calm_music_verse_x as soon as only 1 item is left

When a fight event occur, I would like to empty the queue then add new set of music Queue content: [fight_music_verse_2 fight_music_intro] with the same strategy of filling the queue to not let it get empty

klein-j commented 6 months ago

There are a number of issues with the queue implementation, see my comments here:

https://github.com/jarikomppa/soloud/issues/291

I fixed some of them and also added a queue::pop function which can remove elements from the queue. I believe this could solve your problem.

Code is here: https://github.com/klein-j/soloud_fixed/tree/soloud_fixed