Why computers only count to one
Humans count with ten digits, 0 to 9, probably because we have ten fingers. That’s a historical convention, not a law of nature. Computers work in base 2, in binary, for two reasons. The main one is the component they’re built from.
The transistor is a switch
The building block of every processor and every memory chip is the transistor. In digital use it works as an electrical switch with no moving parts: a small voltage at its input (the gate) opens or closes the path for a larger current. A switch can be in one of two states, open or closed, so the information it holds is one bit: 1 or 0. The switches are connected into logic gates (AND, OR, NOT), and from those you build addition, comparison and memory. A processor today contains tens of billions of these transistors, and each one is a switch.
And for a decimal computer? You’d need a component that holds ten stable states and switches between them quickly and at a tiny cost, by the billion. A transistor works best, cheapest and fastest at the extremes, fully off or fully on, not at in-between levels. A two-state switch is the simplest component to make at that scale. Some early computers did work in decimal, but binary won.
The second reason: noise
Every wire and component adds a little noise to the voltage. If you have to tell apart ten voltage levels close to each other, the noise causes errors. If you only have to tell “high” from “low”, there’s a big margin, and the noise changes nothing. That’s what makes it possible to chain billions of operations without errors piling up.
As the CV Lab shows, in an analog synth the voltage itself is the information: a difference of 1/12 of a volt is a semitone, so any noise is heard as a pitch deviation. In digital, the information is a number, and the number is kept perfectly even if the voltage in the wire wobbles a little.
Bits and bytes
A bit is the smallest digit: 0 or 1. One bit alone doesn’t say much, so bits are grouped. A group of eight bits is called a byte.
Each bit in a byte has its own value, and each value is double the one before it: 1, 2, 4, 8, 16, 32, 64, 128. To find which number a byte represents, add up the values of the bits that are “on”. For example: 64 + 32 + 16 + 8 + 4 = 124.
Build a byte yourself
Click a bit to turn it on or off, and see how the number changes in decimal and hexadecimal. The buttons below load numbers that show up in MIDI.
Hexadecimal: shorthand for binary
Binary is long and awkward to read, so programmers and audio engineers write bytes in hexadecimal, base 16, with the digits 0 to 9 and the letters A to F. Each hexadecimal digit stands for exactly four bits, so a whole byte is just two digits, from 00 to FF. That’s how MIDI bytes are written, and that’s how you’ll see them in the demo in the article on MIDI.
How many values can you store
With one bit there are two values. Each additional bit doubles the number of possibilities. With n bits you can represent 2n different values:
| Bits | Number of values | Where you’ll meet this |
|---|---|---|
| 1 | 2 | A switch: on or off |
| 7 | 128 | A MIDI data value, 0 to 127 |
| 8 | 256 | A whole byte, 0 to 255 |
| 14 | 16,384 | MIDI pitch bend, two 7-bit bytes |
| 16 | 65,536 | The bit depth of a CD |
| 24 | 16,777,216 | A common bit depth for studio recording |
This is where one of MIDI’s limitations comes from: a parameter like cutoff has only 128 values, and a slow sweep can sound like steps. That’s why pitch bend gets two bytes, and 16,384 values are much smoother.
From sound to numbers: sampling and bit depth
Sound is a vibration of air pressure, and in a microphone it becomes a continuously changing voltage, just like the CV in the CV Lab. To store it in a computer, the continuous voltage has to become a list of numbers. Two settings determine how that’s done, and you’ll see them in every DAW:
- Sample rate: how many times per second the voltage is measured. On a CD it’s measured 44,100 times per second, and each measurement is called a sample.
- Bit depth: how many bits each measurement gets, in other words at what resolution the voltage level is written. On a CD each sample is 16 bits, meaning 65,536 possible levels.
What sampling looks like
The blue line is the original sound. Each sample is shown as a “lollipop”: its height is the stored value, after rounding to the nearest level. Fewer bits mean fewer levels and a bigger rounding error. Fewer samples per cycle mean less detail.
Many books and programs draw digital audio as steps, as if each sample lasts until the next one. That drawing is meant to make things easier to understand, and it isn’t what actually happens. Samples are a list of numbers, like a column in a spreadsheet: each sample is one value at one moment, and between one sample and the next there is nothing. That’s why the more accurate view is the lollipop view in the demo. Real steps exist only briefly inside the converter, in a stage called Sample & Hold, where the voltage is held steady until the measurement is finished. On playback, the digital-to-analog converter and a filter after it turn the samples back into a continuous, smooth wave. The “Steps” button in the demo shows the familiar drawing, so you can compare.
It’s like a low-resolution image: when you zoom in you see big squares, but those squares are just how the software displays the pixels. The file stores only one value per point.
An excellent, in-depth explanation, with live demos on real test equipment: D/A and A/D | Digital Show and Tell, by Monty Montgomery of Xiph.org.
The sample rate sets the highest frequency you can store
To capture a frequency you need at least two samples per cycle. That gives the Nyquist rule: the highest frequency you can store is half the sample rate. At 44,100 Hz that’s 22,050 Hz, above the limit of human hearing, which is about 20 kHz. Frequencies above the limit don’t disappear; they “fold” down and are heard as tones that weren’t there. The effect is called aliasing, and you can hear and see it in ADC Lab.
Bit depth sets the noise
Rounding each sample to the nearest level creates a small error, and that error is heard as background noise called quantization noise. Each additional bit halves the step size and lowers the noise by about 6 decibels. So the dynamic range is roughly 6 × the number of bits:
- 8 bits: about 48 dB. Clear background noise.
- 16 bits: about 96 dB. Enough for listening.
- 24 bits: about 144 dB. More than the range of any analog gear. Recording at 24 bits leaves plenty of headroom without getting close to distortion.
Bitrate and calculations
Bitrate is the number of bits needed to describe one second of sound, usually measured in thousands of bits per second (kbps). The place you’re most likely to meet it is streaming: music and video services offer quality settings like 128, 256 or 320 kbps. The higher the bitrate, the more faithful the sound is to the original, but it needs more bandwidth and more space. Streaming services use compressed formats like MP3, AAC and Ogg Vorbis, which drop some of the information the ear hears less to make the file smaller, so their bitrate is much lower than that of an uncompressed file.
To understand how much they save, it’s worth calculating how much space uncompressed audio takes (PCM, like WAV). The formula:
For example, a CD: 44,100 × 16 × 2 = 1,411,200 bits per second, about 1,411 kilobits per second. To get bytes, divide by 8: 176,400 bytes per second, and about 10.6 megabytes per minute. For comparison, a 320 kbps stream is about 4.4 times smaller than the CD’s 1,411, and a 128 kbps stream about 11 times smaller. Compression is what lets you stream music without overloading the network, and the price is losing some of the information, which at a low bitrate you can already hear.
How much space does sound take
Choose settings and see the bitrate and the size. Here a megabyte is a million bytes.
Where you’ll meet this
- MIDI: the cable carries 31,250 bits per second, and each byte travels as about 10 bits, so about 3,125 bytes per second. CD audio moves 176,400 bytes per second, about 56 times more. That’s why MIDI sends short messages and not sound. Read the article on MIDI.
- ADC Lab: turning a continuous voltage into numbers, with sample rate, bit depth, aliasing and quantization noise: the same principles, on live sound. Open ADC Lab.
- CV Lab: on the analog side, the voltage is the information. Open CV Lab.
- Speaker Lab: what happens after the DAC: the voltage reaches the speaker and turns into movement of a cone and changes in air pressure. Open Speaker Lab.
