The Goertzel Algorithm does a single frequency fourier transform in O(N^2) time.
So for a small number of frequencies it is a good choice.
By comparison the FFT time is O(NlogN). Its like Bubble sort versus Quick sort.
Anyway, looking at https://en.wikipedia.org/wiki/Goertzel_algorithm I find a the code presented misleading. It does not discuss:
1) the need(?) for windowing the sample data
2) the need(?) for Kterm to be an integer or not
3) the need(?) for a final division by N^2 of the Power calculation.
Indeed I have spent a lot of time working through these omissions.
AlanX

Files

ezx_graphics.pdf

Adobe Portable Document Format -
92.72 kB -
07/07/2021 at 05:30

I have decided to drop power calculations because they cause all sorts of problems.

Just let power=amplitude*amplitude; if you really want to use it.

In the end a power calculation needs a load impedance to actually make any sense anyway.

Continuous Mode

What would be really nice is a form of Goertzel's algorithm that is continuous like the exponential smoothing function. Because of the windowing I don't think it is possible?

While the peaks are correct what is that background noise? They call it spectral leakage. Basically Goertzel's algorithm see an impulse/sudden start-up/stop, not a continuous 1v/0v square wave. The purpose of windowing is the get rid of the startup noise.

Here is the Hanning window:

A big improvement but not perfect. Although not the best window to suppress impulse noise, it is the easiest to adjust to preserve the fourier transform magnitudes.

What? Basically the default Hanning window (0.5-0.25*cos(2*M_PI*i/N)) reduces the area of the input signal by 50% resulting in a 50% reduction in the fourier transform magnitude. It is easy to see that multiplying by 2 will fix this problem.

You could work out the adjustment factors for the other windows but not by inspection.

Update

Finally found a reference for this (thanks to Peter Schaldenbrand of Siemens):

I don't think you can use Goertzel's algorithm for wavelets.

Alan