[Dev Log] Providing an Easy Way to Loop Audio
One thing that has always been confusing for me was audio looping.

All of the tutorials I saw required me to download an audio editor tool and then find where I want the audio to loop.

How things work

I looked at the looping specifications and realized that audio players only cared about these two things which are stored as metadata for your audio file:

  • LOOPSTART - when the looping begins
  • LOOPLENGTH - how long the looped section lasts

The end of the loop can be determined by simply adding LOOPLENGTH to LOOPSTART.

The way audio players handle it is as follows

1. Start from the beginning of the song

2. If a LOOPSTART tag exists, it will play for LOOPLENGTH duration, and then go back to the start of the loop.

Or something like that. This will allow you to have your nice intro, and then just loop infinitely so that it will play forever.

Storing Loop Data Externally

Now, this is nice, but it could be improved.

Rather than storing the loop data in each file's metadata, you could optionally store them in a separate file.

The file would indicate

  • The name of the song
  • When it starts looping
  • How long it will loop

And then you could simply write down all your looping data in the file.

Each entry would be called an "audio profile".

Multiple Audio Profiles

Now, not only can you provide loop data for a song, you could potentially provide multiple entries. This would save you from uploading multiple versions of the same file which is a huge cost in terms of bandwidth or diskspace.

In order to support multiple audio profiles for the same song, each entry would contain four pieces of data:

  • The name of the profile
  • The name of the song
  • When it starts looping
  • How long it will loop

Each profile would need to be unique. For example, if the name of your song was battle1, you could use profile names like battle1_normal, battle1_short, battle1_looped, and so on.

Then you would just make a script call to load in certain audio profiles before you start to play the music.

Hopefully, this will make the audio looping process more enjoyable for everyone.