Digital gapless albums

The Dark Side Of The Moon. Sgt. Pepper's Lonely Hearts Club Band. Two albums in rock music's canon that employ a technique known as 'gapless' tracks, where each track blends into the other and with few pauses between tracks. The technique is also common in electronic and classical music and is obviously important when listening to live albums, given crowd noise

Whether you are listening to digital forms of this music or not, when listening to these albums it is important to hear them in the way the artist intended. This blog post lists a couple of ways to ensure your gaps are respected (!).

Firstly, why are gaps between tracks of particular concern to digital music collections? After all, with CDs and physical media the gaps 'just work' (ignoring, of course, the gap between flipping over a tape or record and pressing play ;-) ). There are several reasons: music file format and software support support chief among them.

Early forms of digital music, which relied on 'lossy' music formats such as MP3, suffered from gaps introduced artificially between tracks. These gaps were introduced because of the way the lossy encoding worked; to represent the music the audio was chopped into fixed size 'frames' which, if there was no music left at the end of the track, would leave an empty end to a frame. Because the frame was fixed size, this empty space could not be removed, and thus a gap was introduced.

Fancy Gap

It should be noted that lossless music does not suffer from this problem; another good reason to rip your CDs in lossless format! But many people have a large, existing lossy music library, ripped over time or because they want to ensure compatibility with other music players.

Workarounds were developed to avoid these artificial gaps. For instance, in much the same way as volume normalisation works, metadata could be added to a file to indicate that a given track has empty space at the end of it which should not be played. However, this requires music player support and, digital music being digital music, competing ways of defining this emerged.

As well as the music player software or hardware needing to support any metadata identifying "gaps-that-shouldn't-be", the actual mechanics of pushing the music data through to your speakers also need to support gapless playback. Essentially, your music player must support gapless playback. Programmers visualise this playback as a 'stream' of data. The important thing for gapless playback is that this stream is never broken nor are there extra silences added to the stream. If you consider a normal digital music collection consisting of separate files for each track, the music player/streamer must be capable of appending the bytes from one file immediately following the bytes from the previous file. Thankfully, this is supported by most modern music players.

One other potential evil is crossfade. Crossfade is a technique whereby the final few seconds of a track are played at the same time as the first few seconds of the next, and the volume of the former is reduced as the volume of the latter is increased. Crossfade is useful in certain circumstances, for instance in a shuffled party playlist because the music never stops. Unfortunately, a blind application of crossfade will ruin a gapless album, which essentially has the crossfade decided by the artist, rather than the DJ. Whether this affects you depends on the music player. If your music player must be placed in 'crossfade mode', and then all music is crossfaded, then this is a potential problem because you may forget to switch it off. It's better if you can apply it one playlist at a time.

mind the gap

So what are the strategies for digital gapless albums?

As the old saying goes: garbage in, garbage out. Fix your digital files so they are in lossless form. Really, they should be anyway.

If you must maintain a lossy collection, you can choose a format that allows gapless playback. OGG and WMA both have provision for gapless playback. AAC (normally within MP4 files: .m4a, .m4p) can be gapless when encoded or ripped from iTunes, although normally only when played back through iTunes/iPod/iPhone again.

If you have an existing collection in MP3 form, then it's time to employ some hacks. These hacks only work if your music player supports them, because they involve writing metadata to your music files which your music player must, in turn, know how to read.

Here's the background: when MP3 files are created they are said to be 'encoded'. That is, the music is 'encoded' into the MP3 format (or FLAC, or OGG, or AAC...). The software that does this is an 'encoder'. When you rip a CD, one piece of software typically reads the audio from the CD, and then passes it to an encoder to produce the final digital music file. What you need to do is (re)encode your music files with an encoder that supports gapless albums. The de facto implementation is LAME, from version 3.90.3 onwards. You should configure your CD ripper or music organiser to use LAME and then rip or re-encode your music. By default, LAME will add metadata to identify gapless tracks which, so long as your music player supports it, will result in fully gapless playback.

Gapless playback is important but its implementation in digital music is something of a mess. It's unfortunate that the most common digital music format (MP3) has one of the worst levels of support for it.

Thanks to mikelo, quinn.anya and limaoscarjuliet for the images above.
tags: gapless
blog comments powered by Disqus

The Music Library Management blog

Dan Gravell

I'm Dan, the founder and programmer of bliss. I write bliss to solve my own problems with my digital music collection.