Unit 1 · Digital Information · Lesson 1.6

Analog to Digital

Sound is a smooth, unbroken wave. Bits are whole numbers. Something has to give.

Big Idea 2 — Data

Before this lesson

No Runestone reading. The book doesn't cover sampling — everything you need is on this page.

1

Where We Are

People→ Bits→ Programs→ Internet→ Security→ Big Data→ Impact

Still in Bits, and this is the lesson the last three were quietly leaning on. Letters and colors were already countable things — there are 26 letters, and a pixel already had a number. Sound isn't like that. A sound wave has no steps in it at all, and you're about to see what it costs to force one into numbers.

2

The Hook

🔊  vs  🔊 Two buttons further down this page play the same clip of music. One sounds like music. The other sounds like it's coming through a broken drive-thru speaker.

Nothing was added to the good one. Nothing was distorted on purpose in the bad one. The only difference is how many numbers were written down, and how carefully each one was rounded. Two knobs. That's the whole lesson, and you can hear both of them move.

3

The Idea

Push air and it ripples. A microphone feels those ripples as a smoothly rising and falling pressure — a wave with no gaps and no steps, taking every value in between as it moves. That's analog data: continuous, infinitely detailed, real.

A computer cannot store that. Not "doesn't want to" — cannot. Between any two points on a smooth wave there are infinitely many values, and you already know from 1.3 that a computer has a fixed, finite number of bits. Infinite detail into finite bits does not fit, and no amount of clever engineering changes that.

Sampling. Measure the wave at regular intervals, write down each measurement as a number, and throw away everything between the measurements.

The result is digital data: a list of whole numbers. Not the wave — a list of readings taken from the wave. And there are exactly two knobs that decide how good that list is:

KnobWhat it controlsTurn it up and…
Sample rateHow often you measureyou catch faster wiggles in the wave
Bit depthHow precisely each measurement is roundedeach reading is closer to the true height

Both knobs cost the same thing: bits. And the arithmetic is one line you already know how to do:

samples × bits per sample = total bits

8 samples × 3 bits    = 24 bits          ← a toy example
44,100 × 16           = 705,600 bits     ← one second of CD audio, one ear

Bit depth is the 1.1 rule again with a new name on it: b bits per sample means 2b possible heights a reading can be rounded to. 3 bits gives 8 heights. 16 bits gives 65,536. Round a smooth wave onto 8 possible heights and you can hear the damage; round it onto 65,536 and you can't.

Why 44,100? It looks arbitrary. It isn't. To capture a wave that wiggles up and down f times a second, you have to sample at least 2f times a second — otherwise you measure at the wrong moments and reconstruct a completely different wave. Human hearing tops out around 20,000 Hz, so you need at least 40,000 samples a second, and 44,100 was the standard that stuck. You won't be tested on this — but "at least twice the fastest thing you want to catch" is a good number to have.

Here's the part worth sitting with. Digitizing always loses something. The wave between two samples is gone forever, and every reading was rounded on the way in. That's a round-off error — the same one that drifted the Patriot missile's clock in 1.3, except here we accept it deliberately, millions of times a second, because the alternative is not storing sound at all.

The engineering question is never "how do we avoid losing anything." It's "how much can we throw away before a human notices?" Which means somebody has to decide what counts as not noticing, and for whom. Hold that thought for the Impact Check.

4

Try It

Do it on paper first

Draw a smooth wavy line across a sheet of grid paper — any shape, so long as it's curvy. Now mark every 4th vertical gridline. At each mark, read the height of your curve to the nearest whole line and write that number down. You should end up with a row of numbers and nothing else.

Hand only the numbers to a partner. They plot the points on fresh paper and connect them. Compare to your original. Where did it go wrong — and would measuring every 2nd line instead of every 4th have fixed it?

Now the same thing, with knobs. The white curve is the real sound wave. The green dots are your measurements. The green staircase is all the computer actually keeps.

the real wave (analog) what gets stored (digital) the rounding levels
SAMPLE RATE — how often you measure 32 samples
BIT DEPTH — how precisely you round 4 bits · 16 levels

Now hear it. Same eight-note clip every time — only the two knobs change. Use the sliders above, then press play. Headphones help.

Nothing is downloaded — the sound is generated in your browser from the numbers, exactly like the staircase above.

Drag the sample rate to its lowest setting and play again. That grinding, hollow sound isn't noise being added. It is the absence of the measurements you chose not to take.

Real numbers, so the tradeoff is concrete. CD audio is 44,100 samples per second, 16 bits per sample, two channels: 44,100 × 16 × 2 = 1,411,200 bits per second, which works out to about 10.6 MB per minute and roughly 32 MB for a three-minute song. A traditional phone call runs at 8,000 samples per second and 8 bits: 64,000 bits per second, about 22 times less. Both are "sound." One of them is a decision that you will not need to hear the difference.
5

Vocabulary

You just used all three of these. Now they get names.

analog data Bits
Data with continuously changing values — a smooth wave that takes every value in between, with no steps.
digital data Bits
Data stored as a finite set of discrete values — whole numbers, which is the only kind of thing bits can hold.
sampling Bits
Measuring an analog signal at regular intervals and recording each measurement as a number, in order to approximate the original.
6

Check

Five questions in AP format. Pick an answer to see feedback immediately.

0 of 5 answered
7

Impact Check

Who decides what "good enough" means?

Every sampling choice is somebody deciding how much loss is acceptable — and that person is almost never the listener.

Traditional phone systems carry only a narrow slice of the sound of your voice. It was tuned, decades ago, to be just enough for a typical speaker to be understood by a typical listener on expensive copper wire. It is also why s and f are famously hard to tell apart on a phone call, and why people spell things out — "S as in Sierra." That's not a glitch. That's a bandwidth budget from the last century, still shaping how you're heard.

"Typical" is doing a lot of work in that sentence. A tuning that works for a typical voice can work less well for someone with a speech difference, a strong accent, or a quiet voice — and the same is true of the automatic captioning and voice assistants trained on that audio. Meanwhile the person on a slow or metered connection gets the low-quality stream by default, and the person with a hearing aid may need more detail than average, not less, to follow a conversation.

None of this makes sampling wrong — there is no version of digital audio without it. It means the phrase "good enough quality" is incomplete until somebody says good enough for whom, and it is worth noticing that the people setting the number and the people living with it are usually not the same people.

8

Connections

Came from 1.3 — rounding each sample is round-off error. In 1.3 it was a bug that killed people. Here it's a design decision made deliberately, millions of times a second.
Came from 1.5 — a camera sensor does this too. Continuous light, sampled into a finite grid of pixels, each rounded to whole R, G, and B values. Resolution is a sample rate.
Next in 1.7 — you have now built six layers of representation without once thinking about voltages. That habit has a name, and it's the most important word in this course.
Next in 1.9 — deliberately throwing away detail humans probably won't notice is exactly what lossy compression does. You've just met the idea early.
← 1.5 Images and Color as Bits