Looping Music

Discussion in 'Other' started by DaWrecka, Oct 10, 2019.

  1. DaWrecka

    DaWrecka Pangalactic Porcupine

    Currently, if you as a modder (even if you're just doing it for yourself) want music to loop, the only way to do it is to trim your audio to JUST the looping portion; no intro, no lead-out, nothing. But what if your music track needs an intro? Too bad, so sad. You get to QQ moar. Intro or seamless loop, pick one. It would be really nice if there was a way to specify loop points and have the game loop between those points instead of looping back to the very beginning, every time. That way we could have music with an intro AND seamless looping.

    "But DW," you might say. "How are CF supposed to implement that without some proprietary audio format that will frustrate everyone?" Easy, I say. It would require some recoding of the audio subsystem, but they can do it using an open-source format. Oh look, that format is already supported in the game - Ogg Vorbis!

    Back in the day there was a game by Sega called Phantasy Star Online Blue Burst. Like all PC games it was torn apart by hackers and modders trying to figure out what made it tick. It was quickly found that PSOBB had a fairly ingenious method of making music loop. All of the music in PSOBB was in Ogg Vorbis format. Ogg Vorbis supports custom tags. When a track was supposed to loop, that track needed to have a tag with the name LOOP_START, (I might be misremembering the exact spelling, but that's the basic gist) and a value equalling the number of the desired sample. When the game reached the end of the track, if the track had a LOOP_START tag, instead of looping back to the start of the track, it would instead loop back to the sample numbered in the tag. For example, with no tag it would loop back to sample number zero upon reaching the end of the file, but if a LOOP_START tag was present with a value of 2000000, the game would instead loop back to sample number two million. In this way, making audio that loops seamlessly and infinitely was trivial for anyone with a decent audio editor. (such as the FOSS Audacity)

    If we just had something like this, we could avoid the need for music files approaching a hundred megabytes just to give a dungeon or biome some consistent ambience - and even then a hundred megabytes isn't enough to keep the ambience from dying eventually
     
  2. thomasrika

    thomasrika Yeah, You!

    Last edited: Jun 29, 2020

Share This Page