Inside this lab: screens and terms
Sample rate, bit depth, Nyquist and aliasing, on a sheet of graph paper
The ADC measures the wave at fixed intervals, and every measurement is a sample.
Turn SAMPLE RATE: the gray wave doesn’t change, only the number of columns. Click a dot to see its number.
- The converter doesn’t store the wave itself. It measures its height at fixed time intervals, and every measurement is a sample. The number of measurements per second is the Sample Rate. On the grid, every column is one sample.
- How it works: An internal clock ticks at the Sample Rate. At every tick a Sample & Hold stage grabs the voltage and holds it steady, so the converter has time to measure. At 44,100 Hz there’s a measurement every 22.7 millionths of a second (µs).
- What you see and hear: Each sample is shown as a “Lollipop”: its height is the value that was stored. The samples are a list of numbers, like a column in a spreadsheet, and between one sample and the next there’s nothing. Click a sample to see its number in the side panel. The orange steps (Sample & Hold) happen only for a moment inside the converter, and they aren’t the sound itself.
- Where you meet it: CDs are recorded at 44.1 kHz, video and streaming at 48 kHz, and studios also work at 88.2 kHz and 96 kHz. The Sample Rate is chosen in the audio interface settings, and every DAW sets it per project.
- Read more: Bits, bytes and sampling: what a sample looks like · D/A and A/D | Digital Show and Tell (video, Xiph.org)
Bit Depth sets how many rows the grid has, and every sample is rounded to the nearest row.
Turn BIT DEPTH and watch the rows and the red error lines.
- Every sample is stored as a binary number. The Bit Depth sets how many bits each number has, and so how many possible values there are: 3 bit = 8 values, 16 bit = 65,536 values. On the grid, every row is a possible value, and a sample can only sit where a column and a row cross.
- How it works: The measurement itself is precise, but it has to be written down as one of the rows. The converter rounds every sample to the nearest row (Quantization). The difference between the true value and the row is the quantization error. Every extra bit doubles the number of rows and halves the error, which adds about 6 dB.
- What you see and hear: The red lines are the error. In the side panel you see the binary number of the selected sample, bit by bit. In the audio, the error sounds like noise and distortion under the sound. The fewer the bits, the louder the noise.
- Where you meet it: 8 bit = 256 values (about 48 dB). CD is 16 bit = 65,536 values (about 96 dB). Studios record at 24 bit = 16,777,216 values (about 144 dB, more than any analog gear), to leave plenty of Headroom without getting near distortion. Old samplers like the E-mu SP-1200 worked at 12 bit, and a Bit Crusher effect removes bits on purpose.
- Read more: Bits, bytes and sampling: how many values can be stored
A quiet sound uses fewer rows, and Dither turns its distortion into hiss.
Press Play, play “After the converter”, and turn Dither on and off.
- The Bit Depth is spread over the full height, from the peak down to the negative peak. A quiet sound 20 dB below the peak uses only a tenth of the height, so in practice it has about 3 fewer bits. Dither is very quiet noise added before rounding, so the error turns from distortion into an even hiss.
- How it works: Without Dither the error clings to the shape of the wave and repeats every cycle, so it sounds like distortion: harmonics that weren’t in the sound. Dither scrambles the error. Every sample rounds a little differently, and the error turns into noise unrelated to the sound. The ear tolerates that kind of hiss much more easily than distortion.
- What you see and hear: In the graph, with Dither the dots jump between neighboring rows, and on average they follow the wave. In the audio, the grainy tail turns into a soft hiss, and the sound itself keeps coming through inside the hiss.
- Where you meet it: Dither is added every time Bit Depth is reduced, and above all in mastering, when exporting from 24 bit to 16 bit. Most DAWs have a Dither option in the export window, and mastering plugins offer several types to choose from.
- Read more: Bits, bytes and sampling: bit depth sets the noise
At 24 bit the ceiling is 0 dBFS. In 32 bit float the Headroom is almost infinite, and the peaks aren’t cut.
Switch between 24 bit and 32 bit float, and watch the red line: that’s the ceiling, 0 dBFS.
- Every sample is stored in the file as a number. The height of the wave at the moment of sampling is written down as a number, and the file format decides which numbers can be written.
- At 24 bit there’s a last number. Only whole numbers can be written, from about 8.4 million below zero to 8.4 million above it. The highest number is the ceiling: 0 dBFS.
- Whatever goes past the ceiling is cut, and doesn’t come back. A sample that’s too loud is written as the highest number, and the peak goes flat. That’s clipping. The true height isn’t stored in the file, so turning it down later doesn’t bring it back.
- Headroom is the space up to the ceiling. A sound whose peak is 6 dB below the ceiling has 6 dB of Headroom: it can be turned up another 6 dB before the peaks are cut. At 24 bit, when the Headroom runs out, clipping begins.
- 32 bit float writes every number in two parts, like a scientific calculator. The exponent: which range the number is in, with each range twice as high as the one before. The mantissa: exactly where within the range. Plus one more bit for the sign: above zero or below it.
- That’s why the Headroom in float is almost infinite. When the sound gets louder, the exponent moves up to the next range, and there’s always another range. A sample above 0 dBFS is stored at its true height.
- Precision doesn’t suffer. Every range has about 8.4 million rows. Near 0 dBFS the precision is the same as 24 bit, and for quiet sounds float is even more precise.
- The rows in the graph are drawn as an example. The file has millions of rows. To show the difference, the graph shows 17 evenly spaced rows for 24 bit, and 8 rows per range for float.
- It’s an insurance policy inside the computer. Every DAW calculates in float, so a channel that goes past 0 dBFS in the middle of the mix isn’t cut. A file exported to 32 bit float that came out too loud can be turned down later, with no damage.
- Outside the computer the insurance doesn’t work. The converter at the input (ADC) and the converter at the output (DAC) work with whole numbers. What was cut during recording doesn’t come back, and whatever goes out to the speakers above 0 dBFS is cut. That’s why you bring the level below the red line before the output.
- Some recorders record float right from the input. Some portable recorders use two converters, one for quiet sounds and one for loud ones, and combine them into a 32 bit float file. A final file for distribution is exported at 24 or 16 bit anyway, with Dither.
- Read more: Bits, bytes and sampling: how many values can be stored · Decibel Lab: exporting with clipping and Clip Gain
Above Nyquist, half the Sample Rate, a sound folds over and is heard as a lower sound.
Turn FREQ past Nyquist, and listen to how the sound after the converter goes down.
- To describe a wave you need more than two samples per cycle. So the highest frequency that can be stored is half the Sample Rate: the Nyquist frequency. A sound above Nyquist doesn’t disappear. It folds over and is heard as a different, lower sound. That’s Aliasing.
- How it works: Above Nyquist, the samples of a fast wave land on exactly the same points a slower wave would give. The converter can’t tell them apart, and the DAC plays the slow one. At 16 kHz, a 10 kHz sound comes back as 6 kHz. That’s why there’s an Anti-Aliasing Filter before the converter: a Low-Pass that removes everything above Nyquist before sampling.
- What you see and hear: The green line is what the DAC reconstructs from the dots. Below Nyquist it returns exactly to the gray wave, and above Nyquist it’s a different wave. In the spectrum, the red area is what’s above Nyquist. The sweep makes it clearest: the sound rises, and after Nyquist it goes down.
- Where you meet it: That’s why CD works at 44.1 kHz: half is 22,050 Hz, above the limit of human hearing (about 20 kHz), with room left for the filter. Every audio interface has a built-in Anti-Aliasing Filter. In digital synths and saturation plugins Aliasing is created inside the software, so they have an Oversampling option.
- Read more: Bits, bytes and sampling: the sample rate sets the highest frequency stored
The DAC turns the numbers back into voltage, and the filter smooths the steps back into a wave.
Turn Recon Filter off and on, and compare the orange line with the green line.
- The DAC puts out each number as a voltage and holds it until the next number, so the raw output is steps. The Reconstruction Filter, a Low-Pass at the Nyquist frequency, smooths the steps. What comes out is the same wave that went in, not an approximation of it, as long as it was below Nyquist.
- How it works: The steps are the original wave plus high frequencies above Nyquist, created by the sharp jumps. The filter removes exactly those frequencies. What remains passes through all the dots, and when there are no frequencies above Nyquist there’s only one way to pass between them. That’s why the reconstruction is exact.
- What you see and hear: The orange line is the DAC’s raw output, and the green line is what comes out after the filter. Turn off RECON FILTER and play “After the converter”: above the sound there’s a high, harsh tone. Turn it on, and the sound is clean again.
- Where you meet it: Every audio interface, every phone and every pair of Bluetooth headphones has a DAC with a Reconstruction Filter. It’s like a low-resolution picture: when you enlarge it you see squares, but they’re just the way the software displays the pixels. The file stores one value per point, and the steps in the sound are a stage along the way that the filter removes.
- Read more: Bits, bytes and sampling: digital sound isn’t steps · D/A and A/D | Digital Show and Tell (video, Xiph.org)
Terms in this lab
- ADC · Analog to Digital Converter
- Analog-to-digital converter: measures a continuous voltage, for example from a microphone or a guitar, and turns it into a list of numbers a computer can store and process. Found in every audio interface, phone and portable recorder.
- Sample
- One measurement of the wave’s level at a given moment, stored as a number.
- Sample Rate
- How many samples per second the converter measures, in Hz. The higher it is, the higher the frequencies you can store: up to half of it.
- Sample & Hold
- A circuit that captures the voltage at a given moment and holds it steady until the next one. In a converter it holds the voltage steady until the next measurement, so there’s time to measure it.
- Bit Depth
- How many bits each sample has, and therefore how many possible values: 3 bits = 8 values, 16 bits = 65,536. The more bits, the quieter the noise under the sound.
- Bit
- The smallest digit in a computer: 0 or 1. Each additional bit doubles the number of values that can be written.
- Quantization
- Rounding each sample to the nearest possible value, because only a number from a limited list can be written down.
- Quantization Error
- The difference between a sample’s true value and the value it was rounded to. It’s heard as noise and distortion under the sound, and halves (about 6 dB) with each additional bit.
- Dither
- Very quiet noise added before rounding. It turns quantization error from distortion that clings to the sound into an even hiss the ear tolerates easily. It’s added whenever Bit Depth is reduced, for example when exporting to 16 bit.
- dBFS · Decibels Full Scale
- A unit that measures the level of digital audio relative to the ceiling: 0 dBFS is the highest value, and everything below it is written as negative numbers.
- 32 bit float · 32-bit Floating Point
- An audio file format in which each sample is stored as a number in two parts, a range and a position within the range, so it has no ceiling and can store values above 0 dBFS too.
- Headroom
- The space between the sound’s peak and the ceiling, 0 dBFS: how many dB you can still turn it up before the peaks are cut.
- Clipping
- Cutting off the peaks of the wave when the sound goes past the highest value that can be written: the peaks go flat, and the sound distorts.
- Exponent
- The part of a float number that says which range the number is in, with each range twice as high as the one before.
- Mantissa
- The part of a float number that says exactly where the number sits within the range the exponent set.
- Nyquist Frequency
- Half the sample rate: the highest frequency that can be stored. At 44.1 kHz it’s 22,050 Hz.
- Aliasing
- An effect in which a tone above the Nyquist frequency folds down and is heard as a different, lower tone that wasn’t in the original.
- Anti-Aliasing Filter
- A Low Pass filter before the converter that removes everything above Nyquist before sampling, so it doesn’t fold over.
- Low Pass · Low Pass Filter
- A filter that passes the frequencies below the Cutoff and weakens what’s above it. Here: the Cutoff of the filters in the converter sits at the Nyquist frequency.
- Spectrum
- A display of all the frequencies in a sound and the level of each.
- Oversampling
- Working internally at a Sample Rate several times higher, so harmonics created by processing don’t cross Nyquist and fold over. Found in digital synths and saturation plugins.
- Harmonic
- A sine whose frequency is a whole-number multiple of the fundamental: 1×, 2×, 3×. The first harmonic is the fundamental itself.
- DAC · Digital to Analog Converter
- Digital-to-analog converter: turns the numbers back into a voltage that moves the speaker or headphones. Found in every device that plays sound: an audio interface, a phone, Bluetooth headphones, a digital synth.
- Reconstruction Filter
- A Low Pass filter after the DAC, at the Nyquist frequency, that smooths the steps and brings back the original wave.
All terms on the site