goertzel algorithm calculator
Goertzel Algorithm Calculator guide
The Goertzel recurrence evaluates one frequency from a short record without constructing a full spectrum. Paste a real sample block, set its sampling rate and choose the frequency of interest. The magnitude corresponds to the finite Fourier sum with a rectangular window and no amplitude normalization. It can be evaluated between integer transform bins.
Play the instrument ↑- Default result
- 2 tone magnitude
Calculation and units
Use the coefficient 2 cos(2 pi f divided by Fs). Initialize both previous states to zero. For each input, add the current sample to the coefficient times the most recent state and subtract the older state. After the last input, form the sum of the two final squared states minus their product times the coefficient, then take its square root.
Worked examples
Select a named case in the Worked example control to load these values. You can then edit any input to compare the result.
Quarter rate tone
Real input samples = 1 0 -1 0 · Sample rate (Hz) = 8000 · Analysis frequency (Hz) = 2000.
2 tone magnitude. Squared magnitude 4. Recurrence coefficient 0. Evaluated 4 real samples at 2000 Hz with a rectangular window and no normalization.
The record spans one cycle at the selected frequency. Its raw magnitude is two; amplitude normalization would be a separate step.
Off tone cancellation
Real input samples = 1 0 -1 0 · Sample rate (Hz) = 8000 · Analysis frequency (Hz) = 0.
0 tone magnitude. Squared magnitude 0. Recurrence coefficient 2. Evaluated 4 real samples at 0 Hz with a rectangular window and no normalization.
A DC measurement sums the input samples. The positive and negative values cancel exactly in this record.
Single impulse
Real input samples = 0 1 0 0 · Sample rate (Hz) = 8000 · Analysis frequency (Hz) = 1375.
1 tone magnitude. Squared magnitude 1. Recurrence coefficient 0.94279347. Evaluated 4 real samples at 1375 Hz with a rectangular window and no normalization.
A unit impulse has unit magnitude at every frequency. Moving its index changes phase but the reported magnitude remains the same.
Nyquist sequence
Real input samples = 1 -1 1 -1 · Sample rate (Hz) = 8000 · Analysis frequency (Hz) = 4000.
4 tone magnitude. Squared magnitude 16. Recurrence coefficient -2. Evaluated 4 real samples at 4000 Hz with a rectangular window and no normalization.
Adjacent values alternate at half the sample rate. The reference oscillation aligns their signs so that the four contributions add.
Silence
Real input samples = 0 0 0 0 · Sample rate (Hz) = 48000 · Analysis frequency (Hz) = 440.
0 tone magnitude. Squared magnitude 0. Recurrence coefficient 1.99668363. Evaluated 4 real samples at 440 Hz with a rectangular window and no normalization.
A valid silent block produces zero magnitude at the requested tone. An all-zero input is distinct from an empty sample list.
Noninteger bin
Real input samples = 1 1 1 1 · Sample rate (Hz) = 8000 · Analysis frequency (Hz) = 1000.
2.6131259 tone magnitude. Squared magnitude 6.8284271. Recurrence coefficient 1.41421356. Evaluated 4 real samples at 1000 Hz with a rectangular window and no normalization.
The target is between the integer Fourier bins for four samples. A finite rectangular record can have nonzero response at such a frequency.
Interpreting the result
A quarter-rate cosine and a unit impulse provide complementary checks. The cosine builds up when the analysis frequency matches its cycles. The impulse has the same raw magnitude at every frequency. Compare the squared output when a detector needs relative energy, and preserve identical record lengths and windows when comparing numeric thresholds across time.
Measurement and model limits
A finite block limits frequency resolution and permits leakage from nearby tones. A large magnitude at the selected frequency does not prove the presence of a separate steady tone exactly there. The result is dimensioned by the units of the samples and their count; it has no calibrated sound level or power spectral density meaning on its own.
Answers before you play
Common questions
Must I enter an integer bin number?
Enter a frequency in hertz between zero and half of the sample rate. An integer number of cycles in the block is optional.
How do I apply a Hann window?
Multiply the input samples by the desired Hann coefficients before entry. Account for the chosen window gain when comparing tone amplitudes.
Why does doubling the block affect magnitude?
An aligned coherent tone can accumulate more contributions in a longer duration. Normalize consistently for comparisons across block sizes.
What does the result mean at DC?
At zero hertz the raw magnitude is the absolute value of the sum of all input samples. Opposite-signed samples may cancel even when each has substantial amplitude.