Goertzel algorithm: Relationship of magnitude I've written a quick test app that uses the Goertzel algorithm to determine if a given frequency is present in the signal. This is to pick up DTMF tones and various other signals. The app appears to be working. I'm using the 'magnitude squared' approach in my final stage.

http://www.embedded.com/design/configurable-systems/4024443/The-Goertzel-Algorithm

Now, how does this magnitude relate to all the other variables (especially the amplitude of the source signal)? Most of the implementations determine the presence of a given frequency if the magnitude exceeds some threshold. I want to know how this threshold is determined, and how would I go about selecting a suitable threshold.

EDIT:

OK, I think I've found the answer (I hope). Most implementations of the algorithm state that is will return the 'relative power'. I couldn't find any that stated what it was relative to.

This morning, it dawned on me (pun intended) that it's probably relative to the input signal (duh!). So, if we calculated what the power of the input signal is over all the samples taken, and then compare this to the relative power given by the algorithm, we should have a good idea of the contribution of our target frequency?

Is my understanding correct?
You can potentially base the threshold on the overall energy in the frame. If the tone has, say, 10% or more of the total energy, there is a good bet it's there and not just noise.

In general FFT based algorithms may not be the best choice for this. Unless your tone and your local sample clock are phase-locked, you can't line up the tone on one of the FFT bins (or your Goertzel frequency) so the energy of the tone will "smear" out over multiple frequency bins. The FFT is actually a pretty band band pass filter. 

The alternative would be a time-domain band pass filter with a well defined bandwidth and steepness. This would also get rid of the framing constraint and you can dial in the time constant based on the properties of the signal rather then internal properties of the algorithm.