Pages

Friday, December 24, 2010

Digital Music: Gapless Playback

I use the term "gapless playback" a lot. These days it's kind of essential when talking about music playback. "Advances" in digital music playback have spawned the need for this rather curious term. "Gapless" is basically
"the ability to play one song followed by another song without introducing additional gaps or silence"
Obvious really. It's something that was a standard feature on all music formats and playback devices - vynyl, cassette, CD - until the rise of modern digital music players. Something we took for granted as standard for over 60 years is now an optional extra.

Be warned: this post mightwill turn into a bit of a rant. Gapless playback is something I care about a lot. It's been an absolute deal-breaker with my last four digital music player purchases. It's technically possible, it should just be the minimum acceptable standard.

I'm not going to list all the various gapless solutions and guilty parties on this post, if gapless playback is something that concerns you, do the research.

Disclaimer: gapless isn't an issue all the time, only if you're listening to albums. If you think the album format is dead and music must be listened to as individual songs, shuffled or compiled into playlists, stop reading. Otherwise...

What's the big deal?


If you're thinking "but all my albums have gaps between the songs anyway, what's the big deal", well what about live albums, dance music, prog rock records, etc? Some random examples of bands with studio albums that require gapless playback: The Beatles (Sgt. Pepper, Abbey Road), Pink Floyd (Dark Side of the Moon, The Wall), Dream Theater (Six Degrees, Systematic Chaos), The Prodigy (The Fat of the Land), Wu-Tang Clan (Forever), Nine Inch Nails (Pretty Hate Machine, The Downward Spiral), Slayer (Reign in Blood), Tool (Lateralus), Linkin Park (Meteora, A Thousand Suns), My Chemical Romance (Danger Days).

OK, the Beatles probably were wrong to start the whole "album format" thing without considering the limitations of future music players, but we're stuck with a larger number of albums that the average portable player can't handle. Oops.

Gapless doesn't mean "no gaps"


Yes it's confusing. "Gapless" doesn't mean "no gaps between songs", just "no added gaps between songs". So, if we take the Beatles as an example, Revolver has long gaps between the songs on the record, but Sgt. Pepper and Abbey Road let the songs seamlessly flow into each other. Gapless playback recreates the record exactly as it was.

OK, I'm converted. I want gapless. How do I get it?

  1. Use a "gapless" format eg. OGG, FLAC, MP3 (*)
  2. Buy a "gapless" player eg. iTunes/iPod
*Not all MP3s are created equal
Oh, and just because your format is gapless, doesn't mean your player will handle it. My Sony phone plays OGG files, but it leaves a massive gap between them. Spotify also apparently has issues playing its OGG files gaplessly. However, there are gapless-capable formats for both lossy and lossless, and music players capable of handling them. Gapless playback is available if you want it.

Why is gapless so hard to do?


Well, on vynyl/tape/CD, gapless is built into the format - it's a continuous stream of music, and "tracks" are nothing more than index markers you can fast-forward to. Where digital music is concerned, each track is a separate file, to be unpacked (if compressed) and re-combined into the album/playlist running order.

So really, why is gapless so hard to do?


It's not that hard. Many formats manage to store the necessary information. However, playback requires a little thought. Only a little.
  1. Buffering 101: you need a very basic knowledge of buffering - you need to be uncompressing a track slightly ahead of playing it. If you were to build a music player that:
    1. Played first track (slight delay as the music starts buffering) exactly as it is on the CD
    2. Waited until it finished then thought "oh, there's more?" and went off to fetch the next track
    3. Played second track...
    ...and so on, you'd probably get gaps due to disc access, buffering, etc, creating a time interval of greater than 0.0 seconds between tracks. Remember, those tracks already have whatever gaps (or "no gaps") existed on the CD.

  2. Track Length: The track must know when it begins and ends - astonishingly, MP3s can't be relied on to know how long they are (the original specification only stored "roughly" how long a track was, so you often ended up with the track stored as a number of "frames", the last of which contained the end of the song plus some silence to pad it out), although modern encoders seem to do fine.
To play gaplessly, you need to basically treat your tracks as contributing to a seamless playlist, sort of like re-creating a CD on the fly.

But surely if gapless was a problem they'd have fixed it by now?


MP3s have been around for years now. The original specification didn't address gapless playback, although subsequent revisions (and decent encoders like the latest LAME) now allow for gapless (it's not guaranteed that MP3s you buy will be gapless though). And subsequent formats (specifically AAC) based on MP3 repeated the same problem. When apple got so fed up with the situation they first fixed it (for iTunes/iPods only, of course) with a hack for not-necessarily-gapless MP3s that was rightly announced as a major new iPod feature. In 2007.

Apple's hack was basically to figure out how long the track should be (the info that OGG, FLAC etc files keep and MP3s originally threw away) so it can be played gaplessly. There's space in an MP3 to store this info (again, modern encoders create gapless files), but as gapless is not part of the original MP3 spec, no guarantees your player will manage to playback properly.

Getting gapless on non-gapless players


A couple of unsatisfactory hacks:
  • The 'Single Track' hack - OK, you could join all the songs on a CD together into one very long track (apple used to offer a 'join tracks' mode in the old pre-gapless iTunes days) but would you really want to?
  • Crossfading - by having your tracks fade-out and fade-in, slightly overlapping, you eliminate gaps. Of course, you also eliminate any sudden powerful track start/end that should be there, any pauses that should be there, etc. Save it for DJ mixes - crossfading is not gapless.

My 20-Year Turntable / Tape Deck / CD Player does Gapless - surely my shiny new MP3 player does too?


Why did gaps ever appear? Why hasn't the gapless problem been completely eradicated? My guess is that people either don't notice or don't care enough to choose a different player, so the extra effort needed to allow gapless playback isn't considered necessary. People buy individual songs or listen to their own playlists. For many, the convenience of the ubiquitous MP3 format far outweighs its many drawbacks (poor sound quality, inefficient compression, no automatic gapless). It took apple six years to get round to fixing this. Sony used to offer gapless (albeit via ATRAC only) but abandoned it along with their hard-drive players. Spotify considered it such a low priority that they took forever to implement it (and their "free" mode is still flaky).

So if you care, do the research and buy gapless. Or just put up with your player/format adding extra gaps between songs.

Note: updated to cover Spotify etc. finally getting gapless.

1 comment:

  1. Actually this problem is now getting more serious. I listen to a lot of DJ-mixes on CD, so gapless is absolutely essential. My portable CD-player broke down the other week. Seems like no-one sells (quality) portable CD-players any more, so I looked for budget alternative in mini-HiFI and similar. SHOCK: 3 OUT OF THE 4 I HAVE TESTED SO FAR DO NOT ALLOW GAPLESS PLAYBACK OF REGULAR, ORIGINAL CDS (not burnt CDs or MP3s)!!! According to the staff this is also standard, not an option! What's going on? ALL my 10-15 CD-players I've owned in the past NEVER had a problem with gapless playback....

    ReplyDelete