On Digital Audio, Codecs, DACs and Bluetooth…

Wave_sound_digital_representation_splitted_channels

The other day, a co-worker, aware of my obsession with audiophile grade equipment, asked if I could recommend a good pair of portable headphones. He was considering the new Bose QuietComfort Wireless 35, which uses Bluetooth and was curious on the quality of sound at a $350 (USD) price point. I immediately went on a whole rant about codecs, DACs, wireless audio (specifically over Bluetooth), and then tried to find and send him a link to some article describing how it all works. I was surprised to find barely any basic write-ups on the technology behind the above topics and how each node in this chain impacts the audio quality, so here we are, kids, my attempt to break it down for you.

Let’s get right down to it, and apologies in advance if I try to speak to you like you’re five. That’s just my way to make sure that we’re all on the same page. First, there is the original recording – so if it’s already crap (as in, your friend sent you a guitar melody he captured with his iPhone), you’re already in the gutter in terms of quality. But, in most cases, I’m assuming you’re about to play back a mastered studio album from your favorite producer, and I’m guessing, with a high degree of certainty, that you will be playing back some digital files (this assumption, by the way, includes a CD). Somehow the music is already stored there in those bits and bytes, and I will conveniently skip the part on how that happens, since you’ve had no choice on that “behind-the-scenes” process anyway. You either downloaded or ripped the CD yourself, and, usually, have that digital data stored on your [portable] playback device in some “file”. So far so good?

Digital Audio

Unless you’re dabbling with analog audio, like a record pressed on vinyl or magnetic tape playing on a reel-to-reel, you’re dealing with a digital representation of an analog original. It’s just an approximation of it, if you will, since we have to capture its truly unlimited essence with numbers. It may sound like the real thing, but it’s not – it’s just a copy.

The digital data which represents the audio is stored in an audio encoded format – this is also referred to as a “codec” (like WAV, MP3, FLAC, etc.). These codecs are used to encode and sometimes compress the stored digital audio even further, mainly for the purpose of saving disk space. This way you can carry more music with you and also stream it over your WiFi and cellular signal. An audio Compact Disc (CD) stores audio in an uncompressed PCM format (so does a WAV and AIFF files, by the way), with the digital representation of an analog waveform sampled at 44,100 times a second (44.1kHz), using a 16-bit integer to represent the final sample value of the amplitude (loudness) of the original analog signal.

Pulse-Code Modulation (PCM)

Original sound waveform (red) with sampling of its amplitude levels (blue dots)

Picture a sound waveform (or use the image above), and imagine measuring the height of that curved line (that’s the amplitude or “volume” of the signal), at very short time intervals (that’s the sample frequency – we’re measuring it 44,100 times per second). That “16-bit” part represents the resolution of the encoded binary number – we’re using 16 bits (‘1’s and ‘0’s) for each sampled value. With 8 bits you can store 256 different levels of sampling resolution (that’s 2 to the 8th power), and with 16 bits, 65536 different levels (2^16). From the example image above (which actually uses 4 bits to store only 16 numbers), we will be storing 8, 9, 11, 13, 14, 15, 15, 15. etc…

OK, are you still with me, or did I already lose you? My point here is that our ‘music’ is digital, and yes, it’s already missing data! This is because we don’t know all of the values in between those blue dots. Based on the Nyquist-Shannon theorem, sampling data at twice the maximum frequency we wish to capture, should be good enough. Since the human upper hearing range is at 20,000 Hz, any rate of sampling greater than 40,000 times a second is ‘theoretically’ OK. And that assumption is a whole other rant I can leave for later, but for now let’s keep going.

“Lossless” vs. “Lossy” Codec

Any “lossless” audio codec, such as FLAC or Apple’s Lossless Audio, is able to use another algorithm to compress the already stored digital audio even further (by as much as 50-60%) without losing any data. I am purposely avoiding the details here, but let’s just say that it works sort of like a compression for a ZIP file, and when you decompress it you can get the original back without any missing data. Again, the whole point behind this compression algorithm is just to save you some space.

A “lossy” format, such as MP3, AAC or Ogg Vorbis, will down-sample (re-sample again) the original signal even further! It does this by throwing away what it thinks is “useless” data (sometimes sounds above certain high and below certain low frequency ranges), or sounds masked by other sounds, that a human ear can not hear. But because of that, you will never be able to get the original recorded data back – it is gone forever! That’s why it’s “lossy” – the data is lost! But… to most people that should still “sound” just fine.

Another thing to consider here is that even MP3s and other lossy formats can have their own levels of compression, usually determined by the encoding bit rate. The latter refers to the number of bits (and eight bits is one byte) per unit of time (in this case, a second) required to store and playback the audio in an interrupted matter – this is again used for size and streaming music over lower bandwidth networks. The higher the bit rate, the more data is stored to represent the audio signal, the higher the size of the original digital file. If you encode all of your MP3s at 320Kbps (kilobits per second), that should still sound pretty good (but never as good as an original or a lossless encoding). As an example note that most web radios such as Pandora, Rdio, and Rhapsody, will stream music at 192Kbps. Apple’s Beats, Google Play and Spotify will stream at 320Kbps (that’s good!). While streaming via your browser from Soundcloud, Mixcloud or Bandcamp is only at 128Kpbs (the lowest and the worst).

DACs

OK. So now we have this data (stored in a digital file, compressed using an audio codec) and we’ll need to revert it back to an analog signal. Why? Because we need to recreate that acoustic pressure with air vibrations, which will hit our human ear, and then perceived and interpreted by our brain as “sound”. With this being its own complex subject, let’s just say that your typical headphones do just that: use a moving coil, that responds to an alternating magnetic field, which moves the air back and forth with its diaphragm. The current (of that signal) that produces this magnetic field is “analog”, so in order to produce this analog signal from its digital data, we need a Digital to Analog Converter, known simply as a DAC (or, in the most lamest terms, a “sound card”). OK?

So, once more, to summarize really quick (skipping all of the cables in between): original audio recording, sampled, stored in a file, compressed even further, read by some device, converted by a DAC from digital to analog signal, sent to your headphones, then into your ear, maybe your brain…

This DAC is very, very important, as it is the sole interpreter of what that analog sound wave should be like, based on its digital input data. The numbers we stored to represent the original signal are nearly good enough to accurately recreate and interpolate the missing data points to produce a smoothly varying signal. The DAC in your iPhone is cheap and crappy! That’s why gearheads like me, spend more money on getting that part just right! Same file converted by different DACs will sound different – never-mind how expensive your headphones are. Yes, the cables, amps and headphones matter too, but playing an MP3 off of your iPhone is already a lost cause! Playing a lossless file through a terrible DAC is just as bad!

585px-Zeroorderhold.signal.svg
Signal reconstruction and interpolation from digital amplitude levels (red) to an analog waveform (gray)

Wireless and Bluetooth

Alright, so we’ve got ourselves some digital audio, and we’ve got those wireless headphones (or a portable speaker) and now we need to send something to it in order to play music. What exactly are we sending and how is it getting there? Well, we can transmit analog signal using frequency modulation (FM) over radio waves, but we know that doesn’t sound all too great. So instead we’ll use a wireless technology called Bluetooth, to transmit data over short-wavelength radio waves from your sender to receiver.

Without going into technical details behind the implementation (the radio technology is actually called frequency-hopping spread spectrum), the main point here is that we are transmitting digital data here. That means that “something” still needs to convert that digital signal to an analog one. That something is, you guessed it, a DAC, built inside the receiving device. That means that your Bluetooth headphones must have a DAC inside of them! Remember my whole spiel on paying attention to a good DAC? Well, that choice has now been eliminated for you (not a good thing!).

Bluetooth-Logo-1

It actually gets a bit worse. There is a limit to the number of digital bits we can send over this wireless protocol (Bluetooth 1.0 was about 1Mbps and 2.0 can manage up to 3Mbps). That limit to the bandwidth dictates just how much (and how fast) data we can transmit. Great for compressed lossy codecs – not so good for lossless audio. What’s even worse here is that in order to ensure that the data can be transmitted within allowed bandwidth in “real-time” (that is, stream without buffering, etc.), Bluetooth sender will re-sample, re-compress, and re-encode the audio once again! There’s also the latest rage on the aptX codec which claims to improve the transmission of sound via Bluetooth. The thing to keep in mind here is that aptX is still a codec – a proprietary audio compression algorithm – meaning that either way you slice it (unless it’s an aptX Lossless codec), you are still compressing and losing more data along the way.

Don’t get me wrong – Bluetooth is a fantastic technology for digital data transmission, which has built-in auto-discovery, error-correction, security, and all of the wireless networking features. But it’s just not good for audiophile grade sound, as it degrades the original signal even further, in order to recreate it on the other end. If you use, AirPlay for example, DLNA, or other WiFi based technologies, you’re transmitting the original digital audio data (including FLAC encoded files) over the existing network, and hopefully to a better DAC then the one built-in. For example, in my living room, I have a Sonos Connect, which streams my lossless music from my network attached storage (NAS), with its coax digital output connected to my Cambridge Azur 851D DAC, then an amplifier, and only then speakers.

OK… Whew! Did I miss something? Misrepresent a concept? Went too deep (or too narrow) on a particular topic? Should I cover more? Leave me your questions, comments, and most importantly all of your hate mail below!

©

Words by HC

13 thoughts on “On Digital Audio, Codecs, DACs and Bluetooth…

  1. These players indeed have a better DAC chip, but it’s up to you to compare it to similar players out there. I hear that the Sony model you mention (as well as A17) is actually pretty good, and considered checking it out myself. I ended up going with the FiiO X5 instead, which I actually recently reviewed here: http://hcdi.gs/fiiox5

  2. Hey, thank you for your article. I’m really curious about the whole Audio Quality topic. I’m very often on the road, travelling due to my job and listening a lot of music via headphones. I recently switched from Smartphone as a portable device to the Sony NWZ A15 Player and already noticed a step forward in quality. I’m also using the Audioquest Dragonfly as DAC. Any comments on the DAC of the Sony Player itself?

    1. Hey Matthias. The “high-res” players indeed have a better DAC chip, but it’s up to you to compare it to similar players out there. I hear that the Sony model you mention (as well as A17) is actually pretty good, and considered checking it out myself. I ended up going with the FiiO X5 instead, which I actually recently reviewed here: http://hcdi.gs/fiiox5

      I also have the Audioquest Dragonfly and use it on my MacBook Air at work. Definitely a step up from the internal DAC (soundcard) and is great for on the go. Sounds like you’re on the right path, especially if you notice the difference yourself! (This morning I re-listened to an album I used to love a decade ago, and definitely heard brand new things I haven’t noticed before!)

  3. Thanks for this article. However, you throw in the sentence “The DAC in your iPhone is cheap and crappy” without expanding on it. What does this mean? What can someone who listens to music on their iPhone do about it?

    1. Hey Tim. Thank you for calling me out on that.

      What I meant by “cheap” is that the actual chip that converts the digital signal to analog costs Apple about $5 (it’s the Cirrus Logic 338S00105 in 6s, I believe). Although it’s able to interpolate the signal, it’s very noisy (adds other random stuff) and it’s clock is not very good (the clock is needed to properly time events — remember our signal is amplitude over time period, so if that’s skewed, the sound wave will come out distorted).

      Audiophiles tend to invest in higher precision DACs, utilizing better components that reduce noise, jitter and improve audio path. Unfortunately, for Apple users, that means investing in a portable DAC (like the Beyerdynamic A 200 p) which can tap into the iPhone’s lightning port to extract the digital data. Apple is being annoying unsupportive of this approach, and is charging the manufacturer a hefty price to “unlock” the digital data port, the cost of which the company in turn passes on to a consumer, which is why most of these portable devices start at $300 (USD)… Despicable, right?! There is no other way around it, I’m afraid [and Apple knows it!] :(

      1. Thanks for your response! Very informative. This is typical Apple behaviour – and very frustrating…

        I do most of my listening on headphones (Audio-Technica ATH-M50x) during my commute, so if there are any ways to achieve an appreciable improvement in sound quality, I’m definitely interested. I’ve tried a few apps that supposedly improve the sound though EQing, but they just seem to make everything a bit harsh.

        I’m seriously considering investing in an independent digital music player with a superior DAC to my iPhone (I have an old iPhone 4s). The most frustrating part is being able to test out a digital audio player before purchase. Not many shops seem to stock them, assuming, I suppose, that most people will listen on their smartphones and not care too much about audio quality…

        Love your blog – thanks again.

        Tim Clarke
        Hidden Shoal

      2. The 2 important numbers to consider in DAC’s and ADC’s are their respective DNL (Differential nonlinearity) and INL (Integral nonlinearity). Although don’t expect to see them used in audio DAC datasheets to often as they usually describe it in dB. A 24-bit DAC has a theoretical maximum SNR of 144 dB and 96 dB for a 16-bit.

        For example a low end DAC may claim 24 bits but once you factor in the loss of 8 bit’s in DNL/INL you are left with 16 bit’s of signal + 8 bit’s of noise (or should that be analogue warmth). Analogue Devices offer 24bit DAC with a claimed 102dB which is not bad for a $5 chip. Although there are other factors.

        A higher end DAC for example may claim 24 bits but with the loss of 4 bit’s in DNL/INL leaving 20 bit signal and 4 bits of noise or about 120 dB. The CS4398 for example claims 120 dB for about $12 a chip.

        I agree that it is despicable the way that Apple have approached the issue but that said I feel that the sooner that we have digital speakers with DSP corrected responses becoming mainstream, the price/performance should benefit a lot of end users. Although that’s probably another analogue vs. digital war.

  4. Ye must know at least this! Nice overview.
    Spotify has an ‘extreme quality’ option but who knows what that means. Don’t go to the trouble of downloading a lot of Flac files if you’re just planning to re-upload them to Google Play Music because there is not a chance that what plays back will reflect what you actually uploaded.

  5. Got QC 35 as a replacement for QC25 and sold them immediately. Waiting for the Fostex X00 Purple heart.

  6. What an exhaustive, clear, simple article you wrote! Thank you so much. Would you please suggest me some Dac brands? I’m from Italy, my budget is around 1000 euro.

    1. Keeping it simple: Cambridge Audio is the best solution for your budget, the same brand used by Headphone Commute. The alternative maybe NAD, but it’s far out of your (and mine) budget. My two cents. Enjoy the sounds you listen to.

  7. HPC, thank you so much!! Great article but depressing really given all the music I listen to is streamed over Bluetooth.

    I have a question though. I use Spotify, Apple Music and also Tidal which is more expensive but meant to have better audio. Is that really the truth or are all the streaming systems pretty much the same.

    Keep up the amazing work you do. Much appreciation from Sydney Australia, jj.

    1. Don’t be depressed… At the end, if it sounds OK to you, it’s fine. I suppose it’s similar to food still tasting good with some sugar alternatives, or a copy of a famous art piece looking splendid on your wall. As long as you’re fine with it, and now you know the real deal, it’s all good!

      Spotify and Apple Music (Betas) are indeed some of the better audio streaming services out there. I use Spotify all the time to listen to newly released albums, but given my obsessive compulsive nature, I end up buying the actual album (on a CD or FLAC directly from the label) and thus “upgrade” my quality.

      Tidal, has a HiFi version, which is basically CD Quality (FLAC 1411Kbps Lossless at 16 bit 44.1kHz). It’s pretty much as good as streaming a CD, *if* your bandwidth (your internet provider) can handle it. I want to check out Tidal, but right now, their catalog is not varied enough for me to drop another $20 (USD) per month… But I guess it’s still growing (you can browse full catalog here: https://listen.tidal.com/)

Comments are closed.