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

Revise AudioController #228

Open
MarkOates opened this issue Aug 9, 2022 · 4 comments
Open

Revise AudioController #228

MarkOates opened this issue Aug 9, 2022 · 4 comments

Comments

@MarkOates
Copy link
Collaborator

MarkOates commented Aug 9, 2022

During TINS 2022, some features felt like they were needed in AudioController. Namely "overplay" features (options on what to do when a sound is triggered even though it is currently playing). Also, in addition to sound_effects and music, consider adding a separate ambience.

Some basics ideas:

Sound needs:

  • emit_event on finish This is not possible. It looks like the only strategy is to have the AudioController poll currently active samples.

AudioController needs:

  • instances of AudioRepositoryElement containing
    • played_at
    • paused_at
    • replays_remaining

AllegroFlare/AudioRepositoryElement needs:

  • overplay_strategy

Here, an overplay_strategy can be one of the following. That is, "if the audio is currently playing...":

  • ignore: ...do nothing
  • restart: ...stop the current playing instance of the sample, and restart it.
  • restart_if_delay: ...restart the current instance of the sample if an amount of time has passed from the time it was started (will need to take "pause" into account). If the amount of time has not passed when the request is processed, then the request will be ignored.
  • enqueue: ...enqueue an additional subsequent replaying of the sample. This replaying will be triggered after the current sample has ended. Replaying will continue until AudioRepositoryElement::replays_remaining reaches 0.
  • enqueue_restart_on_delay: ...same as enqueue, but will replay after a delay rather than waiting until the previous sample has finished.
@MarkOates
Copy link
Collaborator Author

Here's the location where streams stop playing if the play position is greater than the length: https://github.com/liballeg/allegro5/blob/4aa54e6c994af21bc63d8b593673ab3df62390f8/addons/audio/kcm_voice.c#L221

It's also possible that manual audio stopping would occur in other locations, including resetting the stream, etc...

I'm not sure yet where the implicit stopping/starting occurs for ALLEGRO_SAMPLE_INSTANCE.

@MarkOates
Copy link
Collaborator Author

Allegro has ALLEGRO_EVENT_AUDIO_STREAM_FINISHED:
https://liballeg.org/a5docs/trunk/audio.html#allegro_event_audio_stream_finished.

As a similar feature, there also exists ALLEGRO_EVENT_VIDEO_FINISHED here: https://liballeg.org/a5docs/trunk/video.html#allegro_event_video_finished

@MarkOates
Copy link
Collaborator Author

Might be nice to have a "pause" feature, along with preferences on what to do on a pause (continue music @ 50%, stop ambience, mute/hold currently playing samples & sample replay queues)

@MarkOates
Copy link
Collaborator Author

Consider renaming this to Jukebox and Soundboard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant