Demonstration of sampling
What happens when a signal is sampled in the time domain? Sampling theory made simple. Demonstration of sampling, aliasing, oversampling.
June 4, 2023
Stairstep representation of digital signals is very common in audiophile magazines and forums. Such a representation is not wrong, it's just misleading, as we don't hear the "waveform" itself. Only frequency analysis of the sampled signal can reveal the real effect of sampling, and answer the question of what happens to the signal when the signal is sampled in the time domain.
With the following interactive tool the amplitude spectrum of a sampled sine wave can be analized. Quantization and low-pass filter at the output are missing from the model, so we only see the effect of sampling. We can choose between two types of sampling: zero-order hold and pulse (zero-order hold in Wikipedia ➚). Detailed instructions can be found further down the page.
dBFS
Quick guide
Sampling creates new frequency components (called images, image frequencies). If the sampled signal doesn't contain harmonics above the Nyquist frequency then the generated components (images) appear above the Nyquist frequency and they can be removed with a low-pass filter.
If the sampled signal contains harmonics above the Nyquist frequency then certain image components appear below the Nyquist frequency (aliasing).
Nyquist frequency: half of the sampling frequency. At a sampling frequency of 44.1 kHz, the Nyquist frequency is 22.05 kHz.
In order to see the effect of sampling, set the input signal level to 0 dBFS and the frequency to 10 kHz (10000 Hz). Set the DAC output to zero-order hold and the sampling frequency to 44.1 kHz. Select "Show frequency response". Then increase the frequency of the signal generator with the spin button and see what happens...
The output window
The output window displays the frequency spectrum of the sampled sine signal. The red lines are the image components, the blue line is the output signal (component with the same frequency as the original signal). The input signal (output of the signal generator) is not visible on the graph, it can only be adjusted. Depending on the frequency and settings, the level of the output signal and the input signal may be the same or different.
Amplitude spectrum of zero-order hold & pulse out
The amplitude spectrum of a zero-order hold DAC is the absolute value of the sinc function ( sinc(x) = sin(x)/x ).
The amplitude spectrum of a pulse out is the absolute value of the sinc function as well, but its shape is shifted up in the frequency range according to the pulse width. If the pulse width is 1/10 of the sampling interval then the frequency response will be similar of a system with zero-order hold output running at 10x sample rate. There is also a gain loss. If the pulse width is 1/10 of the sampling interval then the gain loss is 20 decibels ( gain_loss = 20*log(10/1) ). (Changing the pulse width doesn't affect the frequency of the image components.)
The pulse output has little significance, as DACs don't emit pulses. The pulse output is interesting for only one reason: the insertion of zeros in the upsampling-oversampling process is similar to pulse output.
Benefit of oversampling
Oversampling doesn't add new information to the sampled signal. In digital-to-analog converters, the benefit of oversampling is that the image components are moved to a higher frequency so a simple, low-order analog filter can be used to remove unwanted components. Mild roll-off of gain above 10 kHz (sinc response) is also corrected.
(Another advantage of oversampling: increasing the sample rate reduces quantization noise. Doubling the sampling rate lowers the quantization noise floor by 3 dB. This means that fewer bits are needed to map a certain dynamic range when the DAC is operating at a sample rate much higher than 44.1kHz or 96kHz.)
Demonstration of oversampling (and the benefit)
Set the level of the input signal to 0 dBFS and the frequency to 20 kHz. Set the DAC output to zero-order hold and the sampling frequency to 44.1 kHz. We can see that the first image component is very close to the audio band (24.1 kHz). If we set the sample rate to 88.2 kHz then the first image component moves up to 68.2 kHz and the level is slightly reduced. The level of the component at 20 kHz that represents the original signal is also corrected.
The following table shows the frequencies and levels of the first image component for various oversampling values. Frequency of the test signal is 20 kHz and the level is 0 dBFS.
| Sample rate | Frequency [kHz] | Level [dBFS] |
| 44.1kHz | 24.1 | -4.78 |
| 88.2kHz (2 x 44.1kHz) | 68.2 | -11.4 |
| 176.4kHz (4 x 44.1kHz) | 156.4 | -18.05 |
| 352.8kHz (8 x 44.1kHz) | 332.8 | -24.47 |
First image of a 20 kHz sine at different sampling rates
This demonstration shows only the result and the benefit of oversampling, not the actual process. In reality, oversampling involves insertion of zero values and a low-pass filter. Insertion of zeros changes the level of image components, but doesn't affect their frequency. Original image components are removed by the resampling filter, a low-pass filter with a cut-off frequency set to the original Nyquist frequency (this filter is also called an interpolation filter because the waveform appears smoother after filtering).
Filtering after the DAC is not required - only strongly recommended
We can't hear image frequencies (the ear has several low-pass filter stages), so why bother with them? Image frequencies have to be removed due to their negative side effects, since they may generate extra heat and distortion in amplifiers and tweeters.
Browser support
Minimum supported browser versions:
| Chrome | Edge | Firefox | Opera | Safari |
| 26 | 12 | 49 | 15 | 7 |
Related articles & software:
Sampling rate discrimination test (online)
Noise perception modeler (white noise)
Speaker Driver Simulation With Room Response

