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.
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.
Finally found a reference for this (thanks to Peter Schaldenbrand of Siemens):