Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Channels finished notifier #9

Open
moisesjpelaez opened this issue Apr 22, 2024 · 1 comment
Open

Channels finished notifier #9

moisesjpelaez opened this issue Apr 22, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@moisesjpelaez
Copy link

moisesjpelaez commented Apr 22, 2024

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
Copy link
Owner

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

  • You can create a few channels for the different sounds you want to play, and then just pick one random channel to play each time the sound should be played. There's no need to re-create channels all the time, it just adds unnecessary memory allocations and stress for the garbage collector.

  • You can use source effects which are constructs that are similar to DSP insert effects but instead of applying changes while the playback is happening, they apply changes to the audio source itself. Using this, you could implement a source effect that chooses a random audio source from a predefined list of sounds each time the channel is restarted (see applyOnReplay).

    I plan to eventually implement a round robin source effect, but feel free to open a pull request for this if you happen to implement one :)

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.

@MoritzBrueckner MoritzBrueckner added the enhancement New feature or request label Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants