How to Calculate Sample Rate

Audio Sample Rate Calculator .calc-container { max-width: 800px; margin: 20px auto; padding: 25px; background: #f9fbfd; border: 1px solid #e1e4e8; border-radius: 8px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; box-shadow: 0 4px 6px rgba(0,0,0,0.05); } .calc-header { text-align: center; margin-bottom: 30px; } .calc-header h2 { color: #2c3e50; margin-bottom: 10px; font-size: 24px; } .calc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 25px; } @media (max-width: 600px) { .calc-grid { grid-template-columns: 1fr; } } .input-group { display: flex; flex-direction: column; } .input-group label { font-weight: 600; margin-bottom: 8px; color: #4a5568; font-size: 14px; } .input-group input, .input-group select { padding: 12px; border: 1px solid #cbd5e0; border-radius: 6px; font-size: 16px; transition: border-color 0.2s; } .input-group input:focus, .input-group select:focus { border-color: #3182ce; outline: none; box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1); } .input-hint { font-size: 12px; color: #718096; margin-top: 5px; } .calc-btn { width: 100%; padding: 15px; background-color: #3182ce; color: white; border: none; border-radius: 6px; font-size: 16px; font-weight: 700; cursor: pointer; transition: background-color 0.2s; margin-top: 10px; } .calc-btn:hover { background-color: #2b6cb0; } .results-area { margin-top: 30px; background: #ffffff; border: 1px solid #e2e8f0; border-radius: 6px; padding: 20px; display: none; } .result-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid #edf2f7; } .result-row:last-child { border-bottom: none; } .result-label { color: #718096; font-weight: 500; } .result-value { font-weight: 700; color: #2d3748; font-size: 18px; } .primary-result { background-color: #ebf8ff; border: 1px solid #bee3f8; padding: 15px; border-radius: 6px; text-align: center; margin-bottom: 20px; } .primary-result .label { color: #2b6cb0; font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; } .primary-result .value { color: #2c5282; font-size: 32px; font-weight: 800; margin-top: 5px; } .article-content { max-width: 800px; margin: 40px auto; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; line-height: 1.6; color: #333; } .article-content h2 { color: #2c3e50; margin-top: 30px; border-bottom: 2px solid #3182ce; padding-bottom: 10px; display: inline-block; } .article-content h3 { color: #4a5568; margin-top: 20px; } .article-content ul { background: #f8fafc; padding: 20px 40px; border-radius: 8px; border-left: 4px solid #3182ce; } .article-content li { margin-bottom: 10px; } .formula-box { background: #2d3748; color: #fff; padding: 15px; border-radius: 6px; font-family: monospace; margin: 15px 0; }

Audio Sample Rate & Nyquist Calculator

Determine the minimum sampling rate required to capture a specific frequency without aliasing.

Human hearing range typically caps at 20,000 Hz
16-bit (CD Quality) 24-bit (Studio Standard) 32-bit Float
1 (Mono) 2 (Stereo) 5.1 Surround
Minimum Nyquist Rate
(2 × Highest Frequency)
Recommended Standard Rate
Resulting Bitrate
Estimated Uncompressed File Size
function calculateSampleRate() { // 1. Get Input Values var maxFreqInput = document.getElementById("maxFrequency").value; var bitDepth = parseFloat(document.getElementById("bitDepth").value); var channels = parseFloat(document.getElementById("channels").value); var durationMins = document.getElementById("duration").value; // 2. Validate Inputs if (!maxFreqInput || maxFreqInput <= 0) { alert("Please enter a valid Maximum Frequency (Hz)."); return; } var maxFreq = parseFloat(maxFreqInput); var duration = durationMins ? parseFloat(durationMins) : 0; // 3. Calculate Nyquist Rate var nyquistRate = maxFreq * 2; // 4. Determine Recommended Standard Rate // Common Audio Standards: 44100, 48000, 88200, 96000, 192000 var standards = [44100, 48000, 88200, 96000, 192000]; var recommended = standards[0]; // Default var found = false; for (var i = 0; i = nyquistRate) { recommended = standards[i]; found = true; break; } } // If Nyquist is higher than all standards, suggest Nyquist + 10% buffer or highest standard logic if (!found) { recommended = Math.ceil(nyquistRate * 1.1); // Custom high rate } // 5. Calculate Data Rates based on Recommended Rate // Bitrate (kbps) = Sample Rate * Bit Depth * Channels var bitrate = recommended * bitDepth * channels; // 6. Calculate File Size // Size (Bits) = Bitrate * Duration(seconds) // Size (Bytes) = Size(Bits) / 8 // Size (MB) = Size(Bytes) / 1024 / 1024 var fileSizeMB = 0; if (duration > 0) { var durationSec = duration * 60; var totalBits = bitrate * durationSec; var totalBytes = totalBits / 8; fileSizeMB = totalBytes / (1024 * 1024); } // 7. Format Output var nyquistDisplay = nyquistRate.toLocaleString() + " Hz"; var recDisplay = recommended.toLocaleString() + " Hz"; var bitrateDisplay = (bitrate / 1000).toFixed(1) + " kbps"; var sizeDisplay = duration > 0 ? fileSizeMB.toFixed(2) + " MB" : "Enter duration for size"; // 8. Update DOM document.getElementById("nyquistResult").innerHTML = nyquistDisplay; document.getElementById("recRateResult").innerHTML = recDisplay; document.getElementById("bitrateResult").innerHTML = bitrateDisplay; document.getElementById("fileSizeResult").innerHTML = sizeDisplay; document.getElementById("resultsArea").style.display = "block"; }

How to Calculate Sample Rate

Calculating the correct sample rate is fundamental to digital audio processing, analog-to-digital conversion (ADC), and understanding data bandwidth. The core principle behind calculating the minimum necessary sample rate is the Nyquist-Shannon Sampling Theorem.

1. The Nyquist-Shannon Theorem Formula

The theorem states that to perfectly reconstruct a continuous signal from its samples, the sampling rate must be at least twice the highest frequency component present in the signal. This minimum rate is known as the Nyquist Rate.

Sample Rate ≥ 2 × f_max

Where:

  • Sample Rate: The number of samples per second (measured in Hz).
  • f_max: The highest frequency (in Hz) you wish to record or reproduce.

Example Calculation

The upper limit of human hearing is generally accepted to be 20,000 Hz (20 kHz). To calculate the minimum sample rate required to capture full-spectrum human audio:

  1. Identify f_max: 20,000 Hz
  2. Apply the formula: 2 × 20,000 Hz = 40,000 Hz
  3. Result: You need a sample rate of at least 40,000 Hz.

This explains why the CD standard was set at 44,100 Hz. It covers the 40,000 Hz requirement plus a small buffer to accommodate anti-aliasing filters.

2. Calculating Audio Bitrate

Once you have determined your sample rate, you often need to calculate the resulting bitrate (bandwidth). The bitrate tells you how much data is processed per second.

Bitrate (bps) = Sample Rate × Bit Depth × Channels

Example: Recording at 48,000 Hz (48 kHz), 24-bit depth, in Stereo (2 channels):

  • 48,000 × 24 × 2 = 2,304,000 bits per second (bps)
  • Divide by 1,000 to get kilobits: 2,304 kbps

3. Common Standard Sample Rates

While you can calculate a theoretical minimum, digital audio hardware relies on standard rates. When your calculation gives you a number (e.g., 40kHz), you should select the next highest standard rate.

  • 44.1 kHz: Standard for CD audio and most consumer music.
  • 48 kHz: Standard for video (DVD, Blu-ray) and broadcasting.
  • 88.2 kHz / 96 kHz: High-resolution audio standards used in professional mastering.
  • 192 kHz: Ultra-high-resolution used in archival and specialized audio design.

Why is Aliasing a Problem?

If you calculate your sample rate incorrectly and set it lower than 2 × f_max, a phenomenon called Aliasing occurs. Frequencies above the Nyquist limit "fold over" and appear as lower, incorrect frequencies in the digital recording, resulting in harsh distortion that cannot be removed later. Always round up your calculated sample rate to ensure fidelity.

Leave a Comment