What Is This?
An interactive tool for understanding digital audio sampling. See and hear how continuous analog signals become digital, and how they're reconstructed back to analog. Adjust parameters in real-time while watching visualizations and listening to the results.
Key Concepts
- Sample Rate: How many times per second the signal is measured. Higher rates capture more detail. Common rates: 44.1 kHz (CD), 48 kHz (video), 96 kHz (high-resolution).
- Nyquist Frequency: Half the sample rate. Frequencies above this cannot be captured accurately and will "alias" to lower frequencies.
- Bit Depth: How precisely each sample's amplitude is recorded. More bits = more levels = less quantization noise. Each bit adds ~6 dB of dynamic range.
- Aliasing: When a frequency above the Nyquist limit is sampled, it appears as a false lower frequency. This is why anti-alias filters are used before sampling.
- Reconstruction: Converting samples back to a continuous signal using sinc interpolation. When the Nyquist theorem is satisfied, reconstruction is perfect.
Signal Parameters
- Sample Rate slider: 4–96 kHz. Use presets (11k, 44.1k, 48k, 88k, 96k) for common rates. The Nyquist frequency updates automatically.
- Bit Depth slider: 4–24 bits. Shows dynamic range (dB) and number of quantization levels.
- Waveform selector: Sine, Square, Sawtooth, Triangle, or Harmonic Series.
- Frequency slider: 20 Hz–96 kHz (logarithmic scale). Presets available. A warning appears when approaching or exceeding Nyquist.
- Amplitude: Signal strength (0.1–1.0).
- Phase: Shift the waveform ±180° without changing sample points.
Tip: Double-click any slider to reset it to default. Click any value display to type a specific number.
Waveform Visualization
Toggle layers to see each stage of sampling:
- Analog (A): The original continuous signal (white line).
- Samples (S): Discrete measurement points (dots).
- Quantized (U): After rounding to bit depth levels (stair-steps).
- Reconstructed (R): Signal rebuilt from samples via sinc interpolation (green line).
- Error (E): Difference between original and quantized (shows quantization noise).
Use zoom controls (+/−) to see fine detail or overview. Zoom levels from 0.5× to 512×.
Spectrum Visualization
Shows frequency content of the signal:
- Analog mode: True spectrum of the original signal.
- Sampled mode: Spectrum after digitization—reveals aliasing artifacts.
- Anti-Alias Filter: Toggle to see what a perfect low-pass filter removes.
- Linear/Log scale: Linear for overview, Log to see low frequencies better.
The red vertical line marks the Nyquist frequency boundary.
Audio Playback
- Original: Plays the analog signal (simulated at high sample rate).
- Reconstructed: Plays the signal after sampling, quantization, and reconstruction.
Parameters can be adjusted while audio plays—changes apply in real-time. Use the volume slider to adjust output level.
Experiments to Try
- Hear Aliasing: Set frequency to 5 kHz, play Reconstructed audio, then lower sample rate to 8 kHz. The tone shifts to 3 kHz (8−5=3). Watch the spectrum to see the frequency fold back.
- See Quantization Noise: Enable the Error layer, then reduce bit depth to 4-bit. The error grows dramatically. Listen to the distortion in playback.
- Compare Reconstruction: At 44.1 kHz, toggle between Analog and Reconstructed layers. With frequencies under 22 kHz, they should match perfectly.
- Phase Independence: Adjust phase while watching Samples layer. The sample points don't move—phase shift happens between samples.
- Waveform Harmonics: Switch to Square wave and watch the spectrum. Lower sample rates start cutting off harmonics.
Keyboard Shortcuts
- Space: Toggle play/pause
- A, S, U, R, E: Toggle waveform layers (Analog, Samples, qUantized, Reconstructed, Error)
- 1: Toggle Waveform view
- 2: Toggle Spectrum view
- + / −: Zoom in/out
- 0: Reset zoom to 1×
Tips
- Click any ? button next to a control for a detailed explanation of that concept.
- The info displays (kHz, dB, etc.) are clickable—type exact values instead of using sliders.
- On mobile, use the ☰ menu button to toggle the control panel.