Thursday, July 25, 2019

Analog To Digital Digital To Analog Converters

What Is a Digital-to-Analog Converter and How Does It Work?

Analog-to-digital and digital-to-analog converters are both crucial components in all digital audio systems, yet they're often taken for granted. As long as your interface is feeding audio into your DAW, you probably don't think much about analog-to-digital conversion — or the digital-to-analog converter that's driving your monitor speakers. And when you're playing a digital synthesizer, the digital-to-analog converter that lets you feed audio into an amp is likely not getting much mindshare.

Yet converters do matter — compare the sound that comes out of a laptop's minijack to the sound of a quality outboard converter fed by one of the laptop's digital ports (e.g., USB), and you'll hear a major difference. Spoiler alert: the outboard converter will sound a lot better.

To understand analog-to-digital converters (ADC) and digital-to-analog converters (DAC), we need to review some audio basics. Sound consists of variations in air pressure, which have peaks and troughs like ocean waves and interact with our ears' hearing mechanism. The information our ears receive travels to the brain, which processes the information. All audio, from an annoying barking dog to a symphony orchestra, is a wave with a varying shape and level. Often, the more complex the sound, the more complex the wave's shape. Visually, when drawn on a graph of amplitude (level) versus time, audio looks like a squiggly line that's called a waveform (fig. 1).

Figure 1: This graph shows air pressure changes created by an orchestra (playing a Beethoven symphony), after being converted into a varying voltage by a microphone. Note that this is a very short piece of audio that's zoomed way in to show the waveform's shape more clearly.

Carving a waveform's outline into a vinyl record creates the record's groove, which looks like a valley under a microscope. When the record plays, the stylus follows this waveform, which causes the phono cartridge to generate voltage variations analogous to the sound's original waveform which eventually drive a speaker. Because the speaker cone follows the waveform motion, it reproduces the same waveform originally pressed into the vinyl record. Note that each stage transfers a signal that's analogous to the input signal — hence the term, analog audio.

Unfortunately, just like band members, analog audio has limitations. For example, a vinyl record's pops, clicks, warps, and surface noise are added to the original sound as undesirable audio "artifacts." A phono cartridge adds its own coloration, dust causes pops and ticks, tape recording adds hiss, and so on. So while the signal appearing at a speaker's output may be similar to what was originally recorded, it will not duplicate the original sound exactly, due to the errors inherent in analog recording, processing, and playback.

Yay! Digital Audio Exists!

Digital audio removes many variables from the recording and playback process by converting audio into a string of numbers, and then passing these numbers through the audio chain (we'll explain shortly why this improves the sound). An analog-to-digital converter converts an analog signal into numbers. Figure 2A shows a waveform that will end up being converted to digital data.

Fig. 2A. Original audio.

Fig. 2B. Audio level is measured at a particular sample rate.

Fig. 2C. Each measured sample is assigned a numerical value that is stored as digital data.

Fig. 2D. A smoothing filter restores the waveform's original shape.

Figure 2: The process of analog-to-digital conversion samples a waveform at a consistent rate and measures the level of each sample and assigns it a numerical value.

A computer takes a "snapshot" of the signal every few microseconds (see fig. 2B), then translates this series of snapshots, or samples, into voltage levels that represent the signal's level variations (fig. 2C). The computer then measures the levels and converts them into a string of numbers (in the form of digital data) that defines these voltage variations. The number of measurements the converter takes each second is the sample rate, also called sampling frequency.

Let's relate this to a typical audio system. A microphone picks up the audio signal and sends it to the ADC for conversion to digital. The computer receives this string of digital information and processes it — for example, delays it before playing it back to create a digital delay, or stores it on a hard disk for digital recording.

So far so good, but since we can't listen to numbers, the recorded or processed digital data has to be converted back into an analog signal that can drive a loudspeaker or headphones. So a digital-to-analog converter converts the string of numbers back to a series of voltage levels.

However, we're not done yet, because we need to smooth that series of discrete voltages into a continuous waveform. A lowpass filter works in conjunction with the DAC to filter the stair-step signal, which rounds off the sharp edges (fig. 2D). We can then take this newly converted analog signal and send it to an amplifier/speaker combination.

Why Digital Audio Maintains Fidelity

Consider the compact disc, which stores digital data on a plastic disc. A laser reads this data and then sends it to a DAC that converts the data back into analog. CDs use error correction that can figure out and replace missing data if there's a minor scratch on the disc, which makes them less likely to skip. When downloading music, even if there's an interruption in your internet connection, a properly designed download engine will assemble the pieces into a file you can play back without interruption.

Even more importantly for musicians, using digital audio preserves quality as audio goes through the signal chain. In the days of analog multitrack recorders, you mixed your song down to an analog 2-track tape, and this introduced additional hiss and distortion. Mastering the tape added more chances for error, as did transferring the audio to a metal stamper that could press records (which in turn could introduce pops, record wear, and warping). At each audio transfer stage, the signal quality deteriorated. Ugh.

With digital recording, you mix numbers to stereo or surround, which creates another set of numbers. (Of course, these numbers also go through a DAC for monitoring purposes so you can hear what you're mixing.) As a result, the final stereo mix will represent exactly what you heard when you mixed the song. Next, you can take that digitally mixed string of numbers and stream it over the net (hopefully losslessly), or copy it to a smartphone's memory, or press the bits into a Compact Disc, and so on. Each transfer is a true clone, a numerically accurate reproduction — not just a copy — of the sound being transferred.

You can think of the ADC at the signal chain's beginning as "freeze drying" the sound, which is not reconstituted until it hits the playback system's DAC. This is why digital audio can sound so clean: it hasn't been subjected to the humiliations an analog signal endures as it works its way from studio to home stereo speaker (although there's still the humiliation of those horrifyingly bad earbuds on commercial airline flights).

Converter Sample Rate and Resolution

Time for a coffee break, because we're about to slog our way through tech-land. But hang in there, because this is important stuff.

A converter's sample rate, controlled by a highly accurate and stable system clock, is one of the most important characteristics of a digital audio system. If a converter has a relatively high sample rate, you can always downshift to a lower sample rate — but you can't increase it to a higher sample rate. Most low-cost converters operate at 96kHz, but 192kHz is becoming the norm.

Another aspect of the conversion process, bit resolution (less commonly called word length), specifies how accurately an ADC measures an input signal. Because each sample measures a signal's voltage at that moment, the more precise the measurement, the more accurate the conversion from analog audio into digital data. A good analogy is a ruler's calibrations. A ruler calibrated in inches can measure length only in inches with certainty, but a ruler calibrated in sixteenths of an inch can measure length with 16 times better resolution. The greater the number of bits, the greater the resolution.

Resolution varies among audio systems. Higher resolution requires more memory to store larger numbers, as well as greater ADC accuracy to take advantage of the higher resolution. As memory and converters have become less expensive, gear in general has progressed toward higher bit resolutions. For example, an audio greeting card's audio may have only 4 bits of resolution. Early digital audio systems used 8 bits, which progressed to 12 bits. CDs use 16-bit resolution, and "high-resolution" audio uses 24-bit resolution. Although a 24-bit file requires 50% more storage than a 16-bit file at the same sample rate, most recording engineers agree that 24-bit recording gives higher sound quality than 16-bit recording. (Fun fact: Perhaps one reason that people initially thought CDs sounded worse than vinyl was because despite CDs having 16-bit resolution, early players often used 12-bit converters. Oops.)

The lower the bit resolution, the greater the distortion — if you can't measure a signal accurately, then you can't reproduce it accurately. However, unlike distortion in the physical world (which tends to increase with higher signal levels), digital distortion increases with lower signal levels because there are fewer bits available for representing the audio waveform (fig. 3).

Figure 3: High amplitude resolution vs. low amplitude resolution — For a fixed amount of resolution, 24-bits in this case, you can define a high-amplitude signal (left) with greater precision (more bits) than a low-amplitude signal (right).

Fortunately, the levels where distortion creeps in on playback are extremely low anyway, and a technique called dithering can reduce the perceived amount of low-level distortion even further. Furthermore, the audio engine inside your recording/mixing program isn't bound by the rules of converter hardware and can offer essentially unlimited resolution once signals are inside the computer.

Why Digital Converter Headroom Matters

Although your software's audio engine has an almost unlimited dynamic range, the converters that handle audio going into, or coming out of, your computer don't. So it's good practice to allow for some headroom — the difference in level between a signal's peak and the maximum level an ADC or DAC can handle. For example, if you're recording and the signal's peaks reach 0 on your software's virtual level meters, then there's no more available headroom in the audio interface's converters. Increasing the level to the interface will produce distortion. But if the peaks register as -6dB, then there's 6dB of headroom prior to the onset of distortion. When recording, many engineers recommend setting digital audio levels at least 6dB below 0dBFS (or lower — peak levels of -12dB or -15dB are common). This accommodates unanticipated peaks, but some people also feel these levels hit an ADC or DAC's "sweet spot," and that performance isn't as good at the highest and lowest levels.

When mixing, one reason to leave a few dB of headroom at the master output is that most digital metering measures the level of the digital audio samples. However, converting digital audio back to analog may result in higher values than the samples themselves, which creates intersample distortion (fig. 4).

Fig. 4A. Original audio being sampled.

Fig. 4B. Highest sample level after raising to 0db.

Fig. 4C. After going through smoothing filter, signal exceeds 0db.

Figure 4: The analog audio waveform sampled in (A) shows the measured sample levels with red dots. Raising the level of the digital audio's samples to the maximum available headroom (B) can exceed the DAC's maximum headroom when going through the smoothing filter (C) that reconstructs the analog waveform. The red section of the curve in (C) would therefore be clipped.

Unless your channel's meters can alert you to intersample distortion, leave a few dB of headroom to avoid this. Besides, you no longer need to slam the levels as high as possible anyway — in today's streaming world, services like YouTube and Spotify will adjust audio for consistent perceived levels.

Digital Audio Limitations and Solutions

When the CD first appeared, it was promoted as "perfect sound forever" — don't you just love marketing slogans? But digital audio, while generally better than analog audio, still isn't perfect.

  • Sampling rate issues. If the system doesn't take samples of the signal level at a high enough sampling frequency, it's harder to reproduce the signal accurately. The sampling rate has to be at least twice the frequency of the highest audio frequency entering the system, so 44.1kHz is the minimum acceptable sample rate for recording.
  • Output filter coloration. As mentioned, a post-DAC lowpass filter converts the stair-step samples into a smooth, continuous signal. However, a filter may add its own coloration.
  • Resolution (quantization) errors. If a digital audio system can measure levels with an accuracy of 1 millivolt (mV, or 1/1000th of a volt), a level of 1mV would be assigned one number, a level of 2mV another number, a level of 3mV yet another number, and so on. Now suppose the computer tries to measure a 1.5mV signal — the computer can't resolve that value, so it has to assign a value of either 1mV or 2mV. In either case, the sample doesn't correspond exactly to the original input level, which produces an error. Actual accuracies are far better than this example, but errors are still possible.
  • Nonlinearity. This is a fancy name for the inaccuracies that occur if the different quantization levels aren't all equally spaced. Referring back to the previous example, we assumed being able to measure to an accuracy of 1 millivolt. But if there are nonlinearities, the converter might convert a 1 millivolt signal to 1.001 millivolts, a 2 millivolt signal to 1.978 millivolts, etc. These inaccuracies change the waveform shape, which causes distortion.
  • Dynamic range limitations. Theoretically, 24-bit resolution has about 144dB of dynamic range (approximately 6dB per bit). But in the real world, 24-bit conversion exceeds the ability of converters to resolve that high a dynamic range due to noise, circuit board layout issues, power supply limitations, and manufacturing tolerances. The practical resolution will more likely be 20 to 22 bitsf
  • Jitter. If the system clock that provides the sample rate isn't stable, the samples representing the digital audio won't be captured or played back with the same time interval between them. You can think of this as "time distortion," because you aren't hearing the right samples at the right time. This results in subtle distortion and is one of the reasons playing back the same digital audio over two different DACs can sound different — one might have higher jitter, while the other has lower jitter.
  • Offset and gain errors. Offset produces an output voltage even when there's no input level. Higher-end converters usually trim a converter's internal circuity after manufacturing to eliminate offset. Converters can also have gain errors, where the output voltage is higher or lower than what it should be in theory. There aren't workarounds you can do for these issues, but higher-end converters take greater efforts to minimize voltage offset and gain errors.

Although digital audio may not be perfect, it's pretty darn close — and continues to improve. However, just because something is "digital" doesn't automatically mean you'll enjoy all the benefits of digital audio. The converters in your smartphone or other consumer devices will not have the same level of quality as converters intended for pro audio.

For example, Dangerous Music's Convert-8 is a high-end, 8-channel DAC that has as-good-as-it-gets specs: 114dB dynamic range (A-weighted), total harmonic distortion + noise (unweighted) of under 0.00188% at +4dBu and under 0.0004% at +22dBu, crosstalk rejection (leakage from one channel to another) of more than 114dBu at 1kHz, and clock jitter under 16 picoseconds (from 100Hz to 40kHz). If you don't know what these specs really mean, suffice it to say they're excellent. However, note that although these are pretty unambiguous specs, not all companies are as rigorous. For example, they might cite crosstalk but choose a frequency where crosstalk is lowest, and not mention the frequency in the spec sheet. Some comparisons are apples to apples, but most are not; this makes it crucial to listen with your ears, not your eyes.

Fortunately, the quality of converter chips is vastly superior to those of the '80s and '90s. Even low-cost interfaces will have respectable specs. For example, the new third-generation Focusrite Scarlett 2i2 quotes 111dB of dynamic range (A-weighted), and TASCAM's 208i specifies -100dB of crosstalk at 1kHz. You'll have a hard time finding a "bad" pro audio interface — but if you can stretch your budget to high-end converters, you'll hear a more open, transparent, "airy" sound quality that's comparable to listening over high-end speakers instead of lower-priced models. Digital audio is great, but it needs to come from, or go to, the analog world — and that's what separates high-end converters from "okay" converters.

Acknowledgement: Portions of this article have been excerpted with permission from 

The Musician's Guide to Audio,

published by Hal Leonard.

No comments:

Post a Comment

Comments Are Moderated And Saved