Aliasing and Nyquist zones
Whatever goes in comes out between 0 and half the sampling rate, and so do its harmonics.
Model notes
Ported from ADCToolbox 0.9.1. fundamentals/: fold_frequency_to_nyquist, fold_bin_to_nyquist, find_coherent_frequency. siggen/nonidealities.py: apply_static_nonlinearity_hd, apply_thermal_noise, apply_quantization_noise. spectrum/: analyze_spectrum. This page is the interactive companion to its examples exp_c01 and exp_d00; python/adc_aliasing.py runs ADCToolbox on the same samples and regression tests compare selected reference captures.
The fold. A sampler at fs cannot tell f from f plus any multiple of fs, while real-tone magnitudes at −f and f coincide (their phases must be conjugated), so every input lands at |f − fs·round(f / fs)|, somewhere from 0 to fs/2. The Nyquist zones are the half-rate steps of the input. In the odd ones the landing follows the input up; in the shaded even ones it runs the other way, and a whole band sampled there arrives with its spectrum turned over.
The samples cannot tell. The blue line and grey input agree at the sampling instants for an ideal sine. The dots also include distortion, quantization and thermal noise, so they need not lie exactly on either curve. That is why a converter needs an anti-alias filter in front, and why a band in a higher zone can be sampled on purpose, as long as the filter passes that zone and no other.
Harmonics fold too. The converter's own distortion puts H2 and H3 at 2f and 3f, and they land where those land. The fold commutes with the multiplication, so the h-th harmonic lands where h times the tone's landing does: this predicts harmonic locations, not arbitrary nonharmonic spurs. The odd number of cycles, coprime with the record, that find_coherent_frequency picks keeps them off the tone and off each other.
Lowering the output sample rate means keeping only one sample in every N, with no filter first, as a monitor or debug port does in exp_d00. It is a second sampler at fs/N: the zones are N times narrower and everything above fs/2N folds again. For separated tones and white noise, tone ratios and total noise power stay approximately unchanged. Relative to the original N × 4096-point FFT of the same capture, the 4096-point output FFT has a noise floor higher by 10·log10 N. Across slider settings the output FFT always has 4096 points, so its white-noise floor stays approximately constant. Colliding tones must be added as complex amplitudes.
Distortion controls. H2 and H3 set polynomial coefficients relative to the undistorted input amplitude. The cubic term also changes the fundamental, so measured dBc may differ slightly from the control value.
The record. 4096 kept samples, so 4096 × N at the converter, a 12-bit quantiser on a 0 … 1 V range with 0.3 LSB of thermal noise ahead of it, as in exp_d00. The tone sits on the odd bin coprime with that length nearest the frequency you ask for, which is why the value snaps as you drag.