MoritzBrueckner / aura

A fast and lightweight 3D audio engine for Kha.
41 stars 3 forks source link

Channels finished notifier #9

Open moisesjpelaez opened 5 months ago

moisesjpelaez commented 5 months ago

I have seen MixChannel.hx has a finished property to check if a track is finished but I'd like to delete an channel as soon as it's finished playing, something like play(destroyOnFinished: bool = true) or soundChannel.onFinished(?callback:Void), instead of checking soundChannel.finished each frame. Is it possible to do this with the current version of Aura or does it need to be implemented?

For context, I'm trying to implement randomized 'steps foley' sounds and uncommented the bit of code in line 113 if (inputChannels[i] == null || inputChannels[i].finished) from MixChannel.hx for a temporary solution.

MoritzBrueckner commented 5 months ago

Hi, at the moment there is no callback like that, but there are other, better solutions for your problem ("round robin" playback):

I'm also open towards implementing channel finished callbacks, but this will require some thought since the callbacks should not be executed in the audio thread.