Description
What problem does this solve or what need does it fill?
Typically in a game you'll have some sort of background music which repeats endlessly, something that is already supported in Bevy. But aesthetically speaking, we would normally want to "ease in" to the track rather than abruptly starting at full volume (avoiding the ugly click and pop).
Yes, we could do this by ramping up the volume, but musically there's a better way: to have a short musical intro section before the loop. (For the outro, we still need to do a fade, since we can't predict where in the song the fade-out will occur).
To implement this, we'll need the concept of a "looping section". Ideally we want the option for the looping section to be encoded in the audio file itself (because specify the sample offset manually in code is generally tedious and error prone).
Audio file formats like .ogg don't officially support looping, but they do support tags, and these are often used to implement looping, as shown the following tutorial:
https://wohlsoft.ru/pgewiki/How_To:_Looping_music_files
What solution would you like?
The tutorial link above shows how to add LOOPSTART
and LOOPEND
(or optionally, LOOPLENGTH
) tags into an .ogg file using Audacity. So the ask here is to:
- Provide a means for these tags to be read once the asset is loaded.
- Provide a way to use the data in these tags to define a looping section in the audio player.
In the future, we can get more elaborate: we can envision an audio file with multiple named sections, such that the game has some kind of internal state machine that determines which section to play next. This would be used for situational music, such as playing threatening music when enemies are nearby.
What alternative(s) have you considered?
There are lots of alternatives, however none of them are implementable in Bevy currently. For example, you could break up the audio file such that each intro and looping section is a separate asset - however, you would still need some way to seamlessly queue up an audio asset to play immediately after another one has finished.
Additional context
Here's another online tool for looping .ogg files:
Metadata
Metadata
Assignees
Labels
Type
Projects
Status