Music Triggers

Music Triggers

1M Downloads

[1.19.2, mod ver 6.2] music does not loop seamlessly

cuboxy opened this issue ยท 6 comments

commented

Describe the bug
music playing in game that is set to just loop infinitely has a very small but noticeable delay before it loops, instead of looping seamlessly. the song file itself loops just fine, but there is like a milisecond of silence before the song plays again

To Reproduce
Steps to reproduce the behavior:

  1. add a trigger to a structure or a mob or something and have it loop infinitely
  2. stay around the thing triggering the trigger so the music can play until the end
  3. there is a small delay before the song loops!!!!!! aaaahhh!!

Additional context
i'm using ogg files, should i be using mp3s?

commented

Have you tried setting up a loop point to avoid it creating a new track? There may be some inherent delay when a track finishes and starts playing again due to how the backend sound engine handles starting a new track vs seeking to a position within a track.

Relevant wiki section

commented

i set up a loop point with the "from" being the very end of the song and the "to" being 0, and the song would just stop altogether once it reached the loop point, so i restarted my game and I think it might have looped properly once but now it's just having the delay again, i set the "number of loops" to 99999 so it would just loop forever but it still had the delay

commented

I tested it a bit more and the looping seems to just not be working at all

commented

A few things to note about loops:

  • The position in a track can only be set if the track is seekable (generally the log will tell you whether or not a track is seekable when it tries to play)
  • In 6.2, ogg files and some external links are not ever seekable, but due to the sound engine being updated this will not be the case in 6.3 when it releases.
  • If a track ends before the mod is able to confirm a loop (it gets checked 20 times per second which is every 50 milliseconds) it will be stopped instead of trying to seek, so you may need 50+ ms buffer on your from time
  • 6.2 has an issue where the counter backing the num_loops parameter doesn't get reset, so you need a big number there for it to work as intended for now (which you do so it's unrelated probably)
commented

All or most of this was fixed in 6.3

commented

I'm gonna mark this as fixed for now since most of this is not going to be a problem in 6.3. Feel free to open another issue for anything specific that pops up again once 6.3 is released