Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

SugarCube 2.12.0 — Split second disruption when looping audio wav files

I'm looping a wav file in my project and I notice that when the music file comes back around and restarts, there's a split second break between the end of the audio file and its loop — IE, it doesn't loop cleanly and sounds like a jerk/skip in the music file. I've tested this in both Safari, Chrome and the web2exe Chromium build just to rule out browser incompatibilities. Is there anything I can do about this?

Comments

  • Two points:
    1. The HTML media elements which back the audio macros do not guarantee seamless looping.
    2. Your audio must be designed to loop, including being gapless, or you'll always have a noticeable transition.
  • For point two, the audio is definitely gapless and designed with looping in mind, and it loops fine outside of Twine; it's totally seamless and doesn't have any jump/skip when it transitions outside of the project.

    Is there anything I can do to deal with the skipping where the loop comes around?
  • Your only real solution to eliminate the transition would be to use the Web Audio API, probably via a library—e.g. Howler.js. You'll lose some older browsers that way, but it shouldn't be too bad. You'll also lose streaming, which may or may not be important to your project—it probably won't be an issue.

    NOTE: Some audio libraries support both the HTML media elements and the Web Audio API—e.g. Howler.js. If using such a library, you must ensure that you configure it to use the Web Audio API—if allowed to use the media elements, you'll be in the same boat as you are now.
  • edited December 2016
    mixvio wrote: »
    Is there anything I can do about this?
    It was discussed at length in an identical thread of my own. Save for TME solution in the last post there's not a lot can be done unfortunately.

    You don't say what the 'sound' is, but one very messy hack I discovered was to note the end time of the track, and then create a 'filler' of the same sound which is about 2 second long and triggered to play 1 second before the main track ends. This way it 'fills' the gap between loops, but as I say this only works on certain sounds. In my case the sound was a generic 'outside' nose (basically a soft wind) so the filler worked to an extent.

  • Jud_Casper wrote: »
    You don't say what the 'sound' is, but one very messy hack I discovered was to note the end time of the track, and then create a 'filler' of the same sound which is about 2 second long and triggered to play 1 second before the main track ends. This way it 'fills' the gap between loops, but as I say this only works on certain sounds. In my case the sound was a generic 'outside' nose (basically a soft wind) so the filler worked to an extent.

    It's the backing music track, so I don't think that will work. I may have to get the musician to build the loop around that pause, so it cycles cleanly. A bit frustrating, but it is what it is I guess.
Sign In or Register to comment.