From the course: Digital Audio Foundations

Digital to analog conversion

From the course: Digital Audio Foundations

Start my 1-month free trial

Digital to analog conversion

- To actually hear digital audio we first need to run it through a Digital to Analog Converter, or DAC for short. The analog output of the DAC can then be sent to a power amplifier and played on speakers or headphones. DACs can work in different ways electrically under the hood but they all do pretty much the same thing. They go through each sample and produce an analog voltage that matches that sample's measurment at the appropriate time based on the sample rate. Those voltages pass through a reconstruction filter so that the final output is a smooth analog wave form. Contrary to what you might see on your computer screen, the sampled sound is not made of blocky stair steps or jagged connect-the-dots lines. The image shown by the software is not what the sampled sound wave really is. The programmers didn't intend to lie to you, they just took some shortcuts in the visual part. Now you may ask, how could it be possible that digitally sampled audio is a smooth, natural analog-like wave form instead of the jagged connect-the-dots or stair steps that we can see on the computer and that just feels right to imagine? Well, the answer lies in the Shannon and Nyquist Sampling Theorem, which is the mathematical principle all sampled audio is based on. We won't go into the math, but I'll illustrate the general idea by analogy, and then demonstrate and prove it with this analog oscilloscope. Say these two thumbtacks are two sample points. Most audio software will show these points on screen either as a stair step or a straight line. But, the actual sampled audio is more analogous to the curve of this string, which happens naturally due to the laws of physics. Each thumbtack is like a separate voltage that the DAC produces per sample and the string is like the reconstruction filter which turns those individual voltages into a continuous wave form. In the case of the thumbtacks and string, the factors that define this natural curve are the length of the string, the position of the thumbtacks, and gravity. In the case of digital audio, the factors that define the smooth analog output from a DAC are the sampling rate, the measurements of the samples, and wave physics within the reconstruction filter. Let's see how this actually works in digital audio using some software, a DAC, and an analog oscilloscope. First we have a frequency of one kilohertz, which I have recorded at a sampling rate of 44.1 kilohertz. (long beep) As you can see on screen, this looks fairly smooth when you zoom in enough to see each sample. (long beep) And, on the oscilloscope, we see a smooth wave form at one kilohertz. So far, at this relatively low frequency, what we see on screen pretty well matches the actual output of the DAC. Next, let's use a frequency of 10 kilohertz, also recorded at a sampling rate of 44.1 kilohertz. This sound-- (high beep) is quite high frequency. It's still under the Nyquist frequency of 22.05 kilohertz, though, so the sampling theorem tells us that it should be reproduced smoothly and naturally by the DAC. Let's zoom in on screen. What's this? This looks like a real mess. But, when we play it back through the analog oscilloscope, (high beep) and zoom in on the oscilloscope to see the wave more clearly, as you can hear and see it's perfectly smooth. No stair steps, no crazy connect-the-dots jaggedness, just a natural analog sine wave. Finally, let's test a frequency of 20 kilohertz. Again, recorded at a sampling rate of 44.1 kilohertz. This sound is at the very limits of human hearing, and unless you're a teenager or younger you probably won't be able to hear it at all. Your dog or cat might, though. (very high sound or silence) The so-called wave form in our audio software isn't even recognizable as a sine wave anymore. But, sure enough, the analog oscilloscope reveals that it was captured accurately in the digital domain and converted accurately to the analog domain. We can even zoom in further and see that it's perfectly smooth. So why does the wave look like this on screen? Well, the software takes the visual shortcut of just connecting the dots with straight lines instead of calculating and rendering the curves of the true sampled wave form. It would waste a lot of computer power to calculate with math what just happens naturally with physics inside the DAC. It's kind of like how it's more work to calculate the curve of a theoretical string than it is to just hang a real string between a couple thumbtacks. Now, one thing we haven't addressed is, what happens if the original sound has a more complicated curve than this? Say it had another little bump in the middle. Well, by definition, any details in the wave this small are made up of frequencies higher than half the sampling rate. For example, if we imagine these two thumbstacks are samples taken at 44.1 kilohertz, then any shape other than this one, the one that naturally falls into a curve, must be made of frequencies higher than 22.05 kilohertz. The anti aliasing filter in the analog to digital converter will have already filtered those frequencies out back before the original sound was sampled. If the ADC did this properly then the wave form is guaranteed not to include any details that small, and if so, then, the output of the DAC, as defined by the laws of physics, must be the same as the sampled signal. Now, even though a 44.1 kilohertz sample rate can potentially capture sounds with full accuracy, all the way past the limits of human hearing, some people prefer to record at a higher sampling rate like 96 kilohertz or 192 kilohertz. That allows the recording of frequencies even higher than 22 kilohertz. Using more samples per second is kind of like adding more thumbtacks to create a more complex curve. That is, a curve with higher frequencies. But, note that increasing the sample rate past 44.1 kilohertz does not necessarily increase the accuracy or the quality of sounds that are already lower than 22 kilohertz, because that's like putting in extra thumbtacks where the string would already fall naturally anyway. So in theory at least, there's not much extra benefit to recording at very high sample rates. In practice, of course, your mileage may vary because some software and some converters behave differently at different sample rates. Also, there may be circumstances where you need to capture ultrasonics, that is, sounds higher than human hearing, like if you're recording bats or dolphins. There may also be the possibility that humans can somehow sense ultrasonic energy although the majority of evidence from double-blind tests doesn't support that idea. Microphones and speakers have their own frequency limits anyway and many can't capture or reproduce sounds much higher than 20 kilohertz. In our day to day lives, everywhere we look, from our phones to our car stereos to kids' toys and even talking greeting cards, ADCs and DACs are everywhere. It's amazing to think sometimes how, inside these everyday items that are so easy to take for granted there's an awful lot going on.

Contents