Sample Rate to Frequency Calculator

.calc-container { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; max-width: 800px; margin: 20px auto; padding: 25px; border: 1px solid #e1e1e1; border-radius: 12px; background-color: #fdfdfd; box-shadow: 0 4px 15px rgba(0,0,0,0.05); } .calc-header { text-align: center; margin-bottom: 25px; } .calc-header h2 { color: #2c3e50; margin-bottom: 10px; } .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: #34495e; font-size: 14px; } .input-group input, .input-group select { padding: 12px; border: 2px solid #ddd; border-radius: 6px; font-size: 16px; transition: border-color 0.3s; } .input-group input:focus { border-color: #3498db; outline: none; } .calc-btn { grid-column: span 2; background-color: #3498db; color: white; padding: 15px; border: none; border-radius: 6px; font-size: 18px; font-weight: bold; cursor: pointer; transition: background 0.3s; } @media (max-width: 600px) { .calc-btn { grid-column: span 1; } } .calc-btn:hover { background-color: #2980b9; } .results-box { background-color: #ecf0f1; padding: 20px; border-radius: 8px; margin-top: 20px; } .result-item { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid #dcdcdc; } .result-item:last-child { border-bottom: none; } .result-label { font-weight: 500; color: #7f8c8d; } .result-value { font-weight: bold; color: #2c3e50; } .article-section { margin-top: 40px; line-height: 1.6; color: #333; } .article-section h3 { color: #2c3e50; border-left: 4px solid #3498db; padding-left: 15px; margin-top: 30px; } .formula-card { background: #f8f9fa; padding: 15px; border-radius: 8px; font-family: "Courier New", Courier, monospace; margin: 15px 0; border-left: 4px solid #27ae60; }

Sample Rate to Frequency Calculator

Calculate Nyquist limits, frequency resolution, and bin values for digital signals.

Hertz (Hz) Kilohertz (kHz)
Frequency at Index: 43.07 Hz
Nyquist Frequency: 22050.00 Hz
Frequency Resolution: 43.07 Hz
Sample Period: 0.00002268 s

Understanding Sample Rate and Frequency

In digital signal processing (DSP), the Sample Rate (or sampling frequency) is the number of samples of audio (or any signal) carried per second. When working with Fast Fourier Transforms (FFT) or digital oscillators, we often need to know the relationship between a specific digital point (a "bin" or index) and its corresponding real-world frequency in Hertz.

The Nyquist-Shannon Theorem

The most critical concept in sampling is the Nyquist Frequency. This is exactly half of the sample rate. According to the theorem, a signal can be perfectly reconstructed only if the sampling rate is at least twice the highest frequency component of the signal. If you sample at 44,100 Hz, the highest frequency you can accurately represent is 22,050 Hz.

Nyquist Frequency = Sample Rate / 2

Frequency Resolution and Bin Calculation

When performing spectral analysis, the Frequency Resolution determines how "fine" your analysis is. It is the width of each frequency bin in an FFT. To find the frequency of a specific bin, you use the following formula:

f = (k * Fs) / N
  • f: The resulting frequency.
  • k: The bin index or cycle count.
  • Fs: The Sample Rate.
  • N: The total number of samples (Window size).

Practical Examples

Example 1: Audio CD Quality
A CD uses a sample rate of 44.1 kHz. If you take a 1024-sample window and look at the first bin (k=1), the frequency resolution is 44,100 / 1024 ≈ 43.07 Hz. This means each step in your spectrum represents roughly 43 Hz.

Example 2: High Resolution Audio
For a sample rate of 96 kHz and a buffer size of 2048 samples, the Nyquist frequency is 48 kHz. The frequency resolution would be 96,000 / 2048 ≈ 46.88 Hz. This is why larger buffer sizes (N) lead to better frequency resolution but higher latency.

Why Is This Important?

Engineers use these calculations to prevent Aliasing—a distortion that occurs when frequencies higher than the Nyquist limit "fold back" into the lower spectrum. It is also vital for tuning digital synthesizers, designing crossovers, and implementing noise reduction algorithms in communications software.

function calculateFrequency() { var fs = parseFloat(document.getElementById('sampleRate').value); var n = parseFloat(document.getElementById('numSamples').value); var k = parseFloat(document.getElementById('binIndex').value); var unit = document.getElementById('unitType').value; if (isNaN(fs) || isNaN(n) || isNaN(k) || fs <= 0 || n <= 0) { alert("Please enter valid positive numbers for all fields."); return; } // Calculations var frequencyAtBin = (k * fs) / n; var nyquist = fs / 2; var resolution = fs / n; var period = 1 / fs; // Unit Conversion var factor = (unit === "kHz") ? 0.001 : 1; var unitLabel = unit; // Format Results document.getElementById('resFreq').innerHTML = (frequencyAtBin * factor).toFixed(2) + " " + unitLabel; document.getElementById('resNyquist').innerHTML = (nyquist * factor).toFixed(2) + " " + unitLabel; document.getElementById('resResolution').innerHTML = (resolution * factor).toFixed(2) + " " + unitLabel; // Period is usually very small, keep in seconds or ms if (period < 0.001) { document.getElementById('resPeriod').innerHTML = (period * 1000000).toFixed(2) + " μs"; } else { document.getElementById('resPeriod').innerHTML = period.toFixed(8) + " s"; } } // Initial calculation on load window.onload = function() { calculateFrequency(); };

Leave a Comment