Digital Audio Players: Gapless PlaybackContents
What is Gapless Playback?Gapless playback is when a series of audio tracks are played seamlessly, one after another, without any pauses or clicks in between. Unwanted pauses or clicks between tracks can ruin pieces of music which are split across multiple tracks, especially in cases where the music is not silent at the split points. A gapless digital audio player will neither insert nor remove silence between tracks; instead it will play an album exactly the same as a CD player would play the original disc. What isn't Gapless Playback?Gap removal is not gapless playback. Gap removal is when passages of silence on an original CD are removed during playback. It can be useful in a handful of cases -- think "secret tracks" at the end of albums -- but also often goes wrong and removes quiet or silent portions of music which are actually wanted. Crossfading is not gapless playback. Crossfading is when the next track starts before the end of the current track, with the end of the current track fading out as the start of the next track fades in. It can be useful when using a player's shuffle-tracks feature but is usually undesirable when playing an album. Gapless playback is not a feature; the lack of gapless playback is a bug, the same as it would be a bug to add a click or pause in the middle of a track. Unfortunately, many digital audio players fail to do gapless playback. Fortunately, the situation is improving. Who needs Gapless Playback?How much, if at all, you care about gapless playback depends on the music you listen to, on whether you tend to listen to complete albums or individual tracks, and on your personal tolerance for the problem itself.
Some people are perfectly happy with "near-gapless" playback, where there's just a small click between tracks, and some A wide range of music can be affected by non-gapless playback. Dance albums are often continuous pieces of music. Rock has many examples such as Abbey Road by The Beatles. Live albums often feature continuous crowd noise between tracks. Rap and hip-hop albums often have skits separating their tracks. Classical albums often divide different movements in a single piece into tracks and opera is similar. Even some Country & Western albums are affected by the issue -- that's how serious it is -- and back in 2002, when there were no known portable gapless audio players, ignoring compact disc, tape and minidisc which could only hold one album at a time, Hank "The Buffalo" Hicks recorded his seminal take on the problem in the song Dag Nammit, I Would Sell Both My Pigs And Stop Sleeping With My Wife And My Sister For An MP3 Player That Worked Right which reached #7 in the C&W chart. Which was nice. Examples of gaps(To be written.) Why is Gapless Playback Difficult?Before we can talk about gapless playback we need an idea of how digital audio players work and some of the challenges they face even before gapless playback is considered. Memory versus StoragePeople commonly confuse memory and storage. Storage is usually large and relatively slow. On a digital audio player, storage is where all your audio files are and the amount of storage is what determines the amount of music data you can carry around on your player. Memory, on the other hand, is usually much smaller than storage, but also much faster. Memory holds temporary information that goes away when you turn off a device. A player may have several gigabytes of storage, enough to hold several days or even weeks of audio, but only a few megabytes of memory, enough to hold only a minute of audio but, crucially, the minute of audio in memory is the minute of audio you're listening to right now. The Loader and the EmitterWe can think of a digital audio player as having two parts which work together to play a single audio track. Let's call these the Loader and the Emitter. (This is a huge simplification. In reality there may be a long chain of different components which do a number of different jobs. The key detail is that there is a chain where each component depends on the work done by the previous component. For our purposes we can pretend there are only two components in the chain, the Loader and the Emitter.) The Loader's job is to read part of the audio track and put it into memory in a format which the Emitter understands. The Emitter's job is to turn what's in memory into sound signals which are sent to the headphones or line-out socket. Bad and Better PlayersLet's define two types of digital audio player: Bad and Better. On a Bad player there may only be one block of memory. The Loader will load as much of the track as it can into memory. Once that is done the Emitter will then play back what's in memory while the Loader does nothing at all. If the track is too large to fit in memory then there will be a pause when the Emitter finishes as it waits for the Loader to get the next part ready. On a Better player there will be a second block of memory which the Loader can read into while the Emitter is still playing from the first block. If the Loader works faster than the Emitter then, from the moment the first block of the data is ready, the Loader will remain one step ahead of the Emitter and the next part of the track will always be ready when the Emitter needs it. Note that the difference between the Bad and the Better players is not the total amount of memory they have; instead, it is how they use it. Both players might have, say, 32MB of memory As an analogy, imagine you are at a podium to deliver a speech and your notes are on ten folded-up pieces of paper. You don't have time to unfold everything so you get the first page ready, put it on the podium and launch into your speech. If you pause at the end of each page to unfold the next one then Jon Stewart might be telling jokes about your public speaking skills on The Daily Show. A better plan would be to start unfolding the next page in your hands as you're working through the current one from the podium so that you're ready to switch pages the moment you need to. Buffer UnderrunsEven when there are multiple blocks of memory it is still possible for something to cause the Loader to run too slowly, allowing the Emitter to catch up. This situation is called a buffer underrun and is a rare condition on dedicated audio players. Buffer underruns usually happen because data could not be read from disk fast enough. On a portable this can be triggered by sustained physically movement which causes the disk to protect itself from physical damage by shutting down until the movement dies down. The problem could also be caused by a physically failing disk which has to be read several times to get an accurate result, or by an extremely fragemented disk which takes a long time to read because the data is physically spread out. On a computer system the problem can also be triggered by other programs doing so much disk access that the music playback program doesn't have a chance to read its data, as well as by playing music over a network connection which doesn't have enough bandwidth. Buffer underruns can also be caused by trying to decode an audio file which requires more CPU power than is available. This is even more rare since most portable players won't even offer to play a file in a format they cannot decode and most computers, even when under significant multi-tasking load, have enough CPU power to decode every format. When playback glitches happen consistently in particular files it is less likely to be CPU power and more likely to be a corrupted file, a badly encoded file, or a file which has been encoded using a variant of the format which they player doesn't understand; all of which look the same from the player's point of view. Gapless Problem #1: Being ready for the next track.We haven't even talked about gapless playback yet because, so far, we've only talked about playing a single audio track. It is unlikely that a Bad player, with only one block of memory, could ever do gapless playback, but many Better players can't do gapless playback, either. For a player to do gapless playback it has to tackle two problems, the first of which is being ready to start playing the next track when the current track finishes. When the player knows that the current track is about to finish it has to make sure that it starts work on the next track in advance, giving itself enough time to get everything ready. From our high-level point of view this work is very similar to what the Better player, described above, does to ensure that large files can be played in multiple blocks. There are some complications, such as one-off processing which must be done at the start of each file, but these calculations are typically very fast and not a significant factor, at least with the MP3 format. (Some more complex formats formats, for example Vorbis, require significant computations before a file can start playing and this can make gapless playback difficult on a relatively slow processor. It is still entirely possible, though.) In reality, whether a player succeeds at Gapless Problem #1 is usually down to software design rather than any of CPU power, disk speed and format complexity. This aspect of gapless playback should be easy to get right if the software developers keep it in mind from the start but most playback software seems to have been written with the over-simplified aim of playing just one track. Start the playback logic, play one track, then shut-down their playback logic, only to then realise there's another track to play and the playback stuff has to be started again. The system as a whole knew it had another track to play because the tracks are all in a playlist but the thing driving the playlist isn't talking to the thing playing the tracks. It's like driving a car around a race track and turning off the engine at every single corner, only to realise there's more road around the corner and the engine has to be started again. It's incredibly stupid but it's exactly the kind of stupid situation you can find yourself in when programming if you don't pay attention to design and fail to consider things from certain levels. When faced with a system which fails at Gapless Problem #1 the only options seem to be to re-structure large parts of the system or to attempt to make it play new files from scratch so fast that no human could ever notice the delay. Unless you're really lucky with your old code, re-structuring a program is a long, expensive process and requires re-testing the whole thing before you're done. Doesn't sound good, but the second option is probably physically impossible on any current hardware, given how small a delay people can detect. MOOO! Everything below is old and not yet re-written. Examples of gapsThere are thousands of albums out there that should be played back gapless. Incorrect playback matters more for some than others and a pause in one place may cause minor irritation while a pause in another may completely ruin a piece of music. The Beatles' Abbey Road is a classic, well-known example where the medley in the second half is ruined by incorrect playback. There are many more examples but let's pick a particular example to look at: The transition from Track 6 (Parabol) to Track 7 (Parabola) on Tool's Lateralus album is a good test of a player's ability to do gapless album playback. The two tracks are really one piece of music and the transition happens at full volume. In this situation even a fractional second of silence is noticeable and, at least to me, very annoying. Note: The recordings of the Karma and iPod below are intended to demonstrate each player's (in)ability to do gapless playback. They are not intended to demonstrate either player's audio quality. Both players have excellent audio quality but you can't tell from these recordings because they're done via the line-in on my soundcard, encoded at 64kbps, and in most cases have been through a lossy codec twice. Here is what you get if you encode the two tracks to MP3, then decode them and join them together: You can see and hear that there's a small amount of silence between the tracks. This is probably caused by the encoder (LAME 3.9x) padding the end of the track with a bit of silence. If you're looking at the graph and thinking you'll never notice that little tiny glitch then LISTEN TO THE SAMPLE and prove it to yourself. The Rio Karma portable has features for gapless playback which enable it to detect the exact point where a track ends, either by reading a special tag inserted in the file or, if there is no tag, detecting a short, sudden drop to silence at the very end of the file. The Karma moves from one track to the next as if they were one file without so much as a click: Ogg Vorbis is an audio format like MP3 but with explicit support for gapless album playback, provided the device doing the playback does its job properly. With Ogg Vorbis, just as with MP3, the Rio Karma does not disappoint: Now let's look at the market leader, the Apple iPod. As you can see and hear the results are pretty awful: It doesn't matter whether or not silence is added by the MP3 encoder when the player is adding almost a second of silence all by itself. Even with a pair of WAV input files, identical to the original CD tracks, the iPod fails: The 3rd and 4th generation iPods may have reduced the gap time slightly but they have not actually fixed the problem. They still add their own silence on top of any silence added by the audio format. Workarounds with MP3Although part of the problem is MP3 itself, it isn't a lost cause. There are ways to do gapless playback with MP3:
Alternatives to MP3So, gapless playback is possible with MP3, even on portable devices. What about some of the other formats?
Future-Proof your MusicIf you care enough about your music that you're reading this page, you probably want to make sure that whatever format you buy or convert your music to is going to last you into the future. Here are a few suggestions. Take 'em or leave 'em. Refuse to buy DRM'd music. The big record companies only want to sell you music online if they can control what you do with it via Digital Rights Management. In principal, I don't have any problem with them using technology to prevent piracy, but DRM takes away significant rights and choices from consumers and should, in my opinion, be boycotted. There is no one standard format for DRM'd music. The iTunes store will sell you AAC files wrapped in a proprietary FairPlay DRM wrapper. While AAC is a standard format supported by a semi-reasonable number of players, the FairPlay DRM wrapper around it is owned by Apple. Except for HP who are making iPod players to meet demand, Apple have refused to licence FairPlay to anyone, whether they want to sell DRM'd music compatible with iPods or make competing music players which can play music bought from iTunes. Pretty much the only other popular DRM'd music format is WMA. Many more online stores and music players support DRM'd WMA files, but not all of them do... Do you really want to pay money for some music that starts making choices for you about which hardware and software you play it back on in the future? What if you buy a DRM'd WMA album today and next month a kickass new iPod comes out that can't play it? Do you skip the iPod, or buy a second copy of the album? If you buy music from the iTunes store you'd better be really, really sure that for the rest of your life you're only going to buy Apple music players because it looks likely right now that nothing else will play them, HP's version of the iPod aside. Of course, DRM, like any software-based protection can be broken and worked around. The crudest, and worse, workaround is to sample the soundcard output while the music is playing. This obviously leads to pretty awful quality. A slightly better idea is to burn the music to a standard audio CD, which most DRM licences allow, and then rip the CD and compress it to some other format. Aside from wasting a CD, this will still reduce your audio quality because, unless the original DRM'd music was bought in a lossless format, it will have been through a lossy encoder twice and this reduces audio quality. (Although it's technically very different, you can think of each lossy compression as a recording to old fashioned cassette tape. Each recording-of-a-recording will have slightly degraded quality and the same thing happens when you re-compressing music with lossy codecs like MP3, AAC and Ogg Vorbis.) There are more sophisticated ways to unshackle your music from DRM systems which involve tools written by clever people which break the protection and give you a plain AAC or WMA file as a result. The legality of using, or even talking about, these tools varies greatly around the world, depending on how much influence the record industry has over your local authoritarian corporate-led sellout piss-poor excuse for a supposedly-elected-for-the-people government, but they are out there if you look for them, and they're supposed to work quite well. You'll still be stuck with an AAC or WMA file at the end of it, but at least you'll be able to play it on a wider range of hardware/software. Store your albums in a Lossless Format. Ripping hundreds of CD is a pain in the ass and, if you have a sizable collection that you want access to on your computer, is best done once and once only. New and better audio compression formats come and go. Even within a given format, over the years better encoders come along which improve the quality and or filesize of what they produce. Remember when 128kbps CBR MP3s seemed great? Then 160kbps seemed like a better idea. Then VBR encoders came along and that sounded like a good idea so you used them. Then you realised some stuff sounded awful with VBR so you switched to 192kbps. Now the VBR encoders are a lot better so it's worth using them to get higher quality from the same filesize. Now there's also Ogg Vorbis, AAC, MPC and other audio formats... You really don't want to spend a weekend re-ripping all your CDs every time a better audio format comes along, nor do you really want to store all your music in AAC, WMA, Ogg Vorbis or some other format that your current portable player supports but your next one might not. The answer is lossless compression. Use FLAC, which is free and open and can be plugged in to virtually anything. Use Apple Lossless, which isn't open but is trivial to use if you're an iTunes fan. Use WMA Lossless, which also isn't open but is trivial to use if you're a Windows Media Player fan. It doesn't really matter which one you use because they all have the same compression levels (about 50%) and they all support tagging your music with artists, titles, and so on. Since they're lossless you can convert from one to the other if you have reason to later. The important thing is that you have on your harddrive an exact copy of what's on your CD. You can then convert it into whatever lossless or lossy format you need to when it comes time to put it on a portable. If you need to convert your music to another format tomorrow you can do it in a batch overnight and not have to waste days re-ripping CDs, getting those problematic ones to read in you CD-ROM, tediously correcting tags set by the awful online databases, and so on. The only price you pay is harddrive space but, if you've looked recently, harddrives are dirt cheap. 300meg per album instead of 60meg? So be it. My time is worth more money than the disk space. All the advertising and articles I've seen suggest the iPod is god's gift to mankind; it must support some of those workarounds and alternatives, right? It's an expensive device specifically made to play music; surely it does the job properly?Nope. Apple seem more intersted in the way the iPod looks and peripheral features such as address and phonebooks than the ability to play music, despite people sending them complaints for years now. I admit: I was suckered. I hadn't seen a single complaint about the iPod (these days I know where to look :-/). All the advertising and articles made it sound fantastic. It was an expensive device. It was made specifically to play music. I was sure they would have made it able to play albums properly -- it seems a basic requirement of a music player to me -- and so I bought one. For £300 ($500). How wrong I was. If you care about album playback then don't make the same mistake I did and definitely don't rely on the fact that Apple may one day improve their firmware because they don't seem to care. Still, the iPod does look pretty cool so if that's all you're worried about then go for it! To be fair, most other hardware MP3 players are just as bad at gapless playback as the iPod, and many people who don't care about the issue love their iPods. The iRiver players can't do gapless playback. One of their CD players can't play audio CDs gapless, which is a joke. Even Rio, who produce the brilliant Karma, continue to produce a whole range of lesser players that fail to do gapless playback. In short, the DAP industry is a bit lame at the moment and has a long way to go before it's taken seriously by people who take music seriously. It's just that the iPod is the most expensive, the iPod is the one we're all told is the best thing ever made, it's the market leader by a long shot, constantly mentioned and shown gratuitously in the news to the point of utter irritation, white headphones worn with pride like a status symbol by millions of sheep on the train every morning, and the one I wasted my own money on only to discover it's stupid, expensive toy with hacked-together firmware made by a company with its head firmly up its marketing department's arse... Not that Apple don't make some cool computers; I have nothing against them, I just wish people would get a bit more objective about the other things they make and the iPod in particular. (I shouldn't have to say this but a few people have written to me about it so here goes: iTunes, the program you use to play music on your Mac or PC, may well be able to do gapless music playback. I don't use it so I don't know but I'll take your word for it, although people on HA say it can't and I'm more likely to believe them. Either way, this has absolutely NOTHING to do with what the iPod can or cannot do. The iPod does not run a little copy of iTunes inside of it; it's music playback engine is COMPLETELY different. Hope that clears it up. Thanks.) There's an online petition you can sign if you want Apple to fix gapless playback in the iPod. Which portable player should I buy if I care about gapless album playback?I decided to replace my 20gig iPod with something that had the same storage capacity (or better) and which did gapless playback of albums and supported the Ogg Vorbis format. The Rio Karma was the clear winner. In fact, it was the only player that did all that I wanted.
Update History
Thank you!Thanks for reading this page and making it worth writing. Thanks to everyone who cares about this issue as much as I do for making me feel less like an obsessive-compulsive psycho. Turns out more people care about it than I first thought, and thanks to all those who took the time to write a thank-you email (they're not expected but I appreciate them). Thanks to those who have provided additional details and corrections. Thanks to those who spread the word about the issue or the page itself or both. It's not the end of the world if our music has some gaps in it but it still sucks so let's try to do something about it. Image and audio bandwidth provided by GPSoftware, makers of Directory Opus. (Ta Jon! (Even if you did buy a Nano. :-))) CopyrightA short section of Tool's Parabol/Parabola is used to demonstrate gapless playback abilities. These tracks are (C)2001 Tool Disectional, L.L.C./Volcano Entertainment II, L.L.C. and are used here under the assumption that it is fair-use to use a small section of them for demonstration purposes. If you have a problem with this then please email me and I will replace them with some other demonstration. |