Jibble

Author Topic: Sample-Based Loop Points ".logg"  (Read 1883 times)

Sample-Based Loop Points ".logg"
« on: 31 Dec 2012, 02:27 »
I've done a quick search and I couldn't find anything about this on the forums, so forgive me if I've missed it and please point me in the right direction.

I've seen elsewhere on the internet that several players, programs, and games (many fan engines like EDuke32 and RPG Maker) support a type of digital music loop mechanic by adding custom meta-tags LOOPSTART and LOOPLENGTH (or LOOPEND sometimes) which are defined in samples that allow a song to loop back to a specific point. Some programs that utilise this require the digital file to be ".logg" but really it's just a regular Vorbis OGG with added custom metatags. Currently, the only way to do this with digital music is to make two files. One with the intro only, and the second part which comes after and loops forever. Utilizing sample-based loop points seems like a more elegant solution to this, but I don't know what's all involved in implementing it. Is there a plugin for AGS for this functionality already? Or might it be possible to do it manually inside the AGS script logic? How likely is this to be added to AGS as a built-in feature? It seems like it would be a handy thing to have. I can already think of more advanced features if it were built-in. Like, multiple loop points that can be called when the music file is called, how many times it loops, allow it to loop for as long as a certain condition is met and when that condition is false, the file will end normally instead of reaching the LOOPLENGTH point, and things like that.

EDIT: I see that there are already script commands for SeekMP3PosMillis() and GetMP3PosMillis() but it's for milliseconds and not for samples. I submit that having commands for samples rather than milliseconds would offer much more control for the music system. Is there any chance for sample-based commands to get added to AGS? I realize that Chris isn't working on it anymore and AGS is in the hands of the community so I don't know how realistic this is.

Something like this:

if (GetMP3PosSamples() > 2742220)
   SeekMP3PosSamples(48087);
« Last Edit: 31 Dec 2012, 04:30 by MusicallyInspired »
Buy Mage's Initiation OST (Bandcamp)
Buy Mage's Initiation (Steam, GOG, Humble)

Scavenger

  • Cavefish
  • In Four Glorious Colours!
    • I can help with animation
    • I can help with backgrounds
    • I can help with characters
    • I can help with scripting
    • Scavenger worked on one or more games that won an AGS Award!
    •  
    • Scavenger worked on one or more games that was nominated for an AGS Award!
Re: Sample-Based Loop Points ".logg"
« Reply #1 on: 31 Dec 2012, 04:18 »
I managed to do a similar thing with MIDI files once, making them loop before the song ended to a point after the intro, and transition between different files - but I'm not sure the same thing can be done with OGG files simply because the Get/SeekMusicPos function was last I checked, more inaccurate than the MIDI/MOD get/seek functions. I'm not sure if this has been fixed.

But if that's been solved, then I don't see why it couldn't be done. No metadata, though, AGS doesn't grant access to the files themselves.

Re: Sample-Based Loop Points ".logg"
« Reply #2 on: 31 Dec 2012, 04:32 »
Yeah, milliseconds aren't as accurate as the actual samples, as there are about 44 samples within one millisecond (for a 44.1KHz sampled digital track). Which is why I was recommending commands for samples instead. But I don't know how much work that would be. Having multiple tracks with varying sample rates might make things wonky. Unless AGS forces a certain sampling rate on all files? Can the Allegro library work with digital files on a sample-based level? I can't remember.

EDIT: Playing around with Allegro, I see that it does. I successfully looped a music file in a simple Allegro program to the exact sample. Could this native Allegro procedure be tied into AGS's scripting API?
« Last Edit: 31 Dec 2012, 05:03 by MusicallyInspired »
Buy Mage's Initiation OST (Bandcamp)
Buy Mage's Initiation (Steam, GOG, Humble)