jaevelgames Posted December 10, 2014 Share Posted December 10, 2014 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! Quote Link to comment Share on other sites More sharing options...
digitalicarus Posted December 11, 2014 Share Posted December 11, 2014 https://github.com/Hivenfour/SeamlessLoopI used this a while back for a thrust sound on a lander game. https://github.com/digitalicarus/lander/blob/master/js/game.js#L108https://github.com/digitalicarus/lander/blob/master/js/game.js#L275 jaevelgames 1 Quote Link to comment Share on other sites More sharing options...
alex_h Posted December 11, 2014 Share Posted December 11, 2014 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! jaevelgames 1 Quote Link to comment Share on other sites More sharing options...
jaevelgames Posted December 11, 2014 Author Share Posted December 11, 2014 @digitalicarus: Thanks for the tip! I will definitely try this out. @alex_h: I didn't know this, so great tip for the future unless I can get hold of the original! Quote Link to comment Share on other sites More sharing options...
alex_h Posted December 11, 2014 Share Posted December 11, 2014 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 .m4aIt 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 Quote Link to comment Share on other sites More sharing options...
digitalicarus Posted December 11, 2014 Share Posted December 11, 2014 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. Quote Link to comment Share on other sites More sharing options...
jaevelgames Posted December 19, 2014 Author Share Posted December 19, 2014 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! Quote Link to comment Share on other sites More sharing options...
natecombsmedia Posted March 31, 2015 Share Posted March 31, 2015 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. Quote Link to comment Share on other sites More sharing options...
kleepklep Posted December 29, 2015 Share Posted December 29, 2015 I'd be interested in what you came up with. Hopefully you're following this post! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.