Allegro.cc - Online Community

Allegro.cc Forums » Game Design & Concepts » Looping glitches: mp3 versus ogg?

This thread is locked; no one can reply to it. rss feed Print
Looping glitches: mp3 versus ogg?
amarillion
Member #940
January 2001
avatar

I was wondering if anybody else encountered this issue. It appears to be almost impossible to get looping mp3 music without glitches.

I'm now working with a music composer to make tracks for food chain farm We are working in MP3 format. And I started to notice that when looping mp3 audio, there is a noticeable gap or glitch at the looping point. It's just a few milliseconds, but it's enough to notice.

According to this page: Mp3 loops this is a fundamental problem in the mp3 file format. It provides a solution to modify your mp3 file to minimize the glitching, but still that has some disadvantages.

I never noticed this problem before with Ogg/Vorbis. Does this problem just not exist for Ogg? Is the solution here: just use Ogg? (Historically I've always used Ogg because of the nice allegro support, and because of the whole mp3 encoders are evil thing which is no longer relevant).

raynebc
Member #11,908
May 2010

Reading that article, it seems to like it's more of an implementation problem (ie. with Microsoft's APIs) than a problem with the format itself. The author shows that a customized callback function for FMOD eliminates the looping lag entirely.

Kitty Cat
Member #2,815
October 2002
avatar

Looping is a fundamental problem with the mp3 format, due to it not being able to specify an exact sample length. It always aligns to a fixed-size frame, so unless your song ends exactly at the end of a frame, there will be a gap. There are ways around it, such as detecting and skipping the silence at the end of the last frame, but it's a kludge.

Ogg Vorbis and most other formats don't have that problem, and can end on a specific sample avoiding the gap. Vorbis is generally a better format than MP3 anyway, as it compresses better with more quality at the same bitrate. You may even want to give Ogg Opus a try, which compresses even better than Vorbis, if it's supported.

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

Audric
Member #907
January 2001

The inaccurate duration in the file format can also be solved for known files if the user can provide an alternative, more accurate length.

amarillion
Member #940
January 2001
avatar

Something I failed to mention in the OP is that this is for a web game using the Phaser.io (2.X CE) library.

Since last week, I learned a few things. Implementation definitely matters. For example, the audacious music player handles looping mp3's poorly. And looping mp3s on chrome is a LOT better than on firefox. But to really get the transition perfect, I'm going to use OGG, and also bypass phaser, using the webaudio API directly.

It's still a work in progress

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Go to: