Jump to content

Seamless loop?


jaevelgames
 Share

Recommended Posts

I'm totally new at this forum, so this might an old topic. If so, I'm sorry.

 

Anyway, I'm working with a html & javascript game in which i want a 20 second .mp3 to start and then loop.

 

I'm fine with the user interaction to play, and I also got it to loop. But is there a way to make the loop as seamless as possible?

As it is now, there's a notable pause between the end and the start of the mp3.

 

Thanks in advance!

Link to comment
Share on other sites

The simplest solution is to just not use .mp3. If you use .ogg or .m4a instead you should find the sound loops flawlessly, as long as you generate those files from the original uncompressed audio source, not from the mp3 file! The process of compressing to mp3 inserts a few ms of silence at the start of the audio, making mp3 unsuited to looping sounds. I read somewhere that the silence is actually supposed to be file header information but it incorrectly gets treated as sound data!

Link to comment
Share on other sites

If you don't have the original you might still be able to work around this as long as the compression ratio is not too high. If you open the mp3 in a wave editor like Audacity or Adobe Audition you should be able to trim the silence off so that it loops nicely within the editor. Then save it as a new uncompressed .wav or .aif file and use that file to generate the .ogg or .m4a

It will depend on the audio content as to whether you think the end result sounds over-compressed due to having been compressed once to mp3 and then once agin to .ogg or .m4a

Link to comment
Share on other sites

If I remember correctly from experience a couple years ago there was a pause with many source types and the pause was disparate between browsers. That's why this library was loading two copies of the source and sequencing based on the browser offset. Browsers may have fixed this, but it was very frustrating at the time since they were all a bit different.

Link to comment
Share on other sites

  • 2 weeks later...

I got Audacity and trimmed away the silence, saved as .m4a (since .ogg was kind of heavyweight for download) then I used seamlessLoop.js. It worked really well actually!

To bad it's still an issue with the required user-activation on ios Safari...

 

Thanks a lot anyway! I will use this solution in the future, for sure!

Link to comment
Share on other sites

  • 3 months later...

Yeah, ogg works way better than mp3 for simple loops. I know your question has long since been answered, but this topic interests me greatly because it remains a problem in the game audio world—both for programmers and audio / music creators (me).

 

I've been working on a new method for looping seamlessly when other issues arise, such as pops, clicks, and odd reverb. Let me know if you'd be interested in hearing more or if this is still an issue for you and I'll send you the blog post.

Link to comment
Share on other sites

  • 8 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...