# Similarity between Goertzel filter and bandpass filter

Started by March 25, 2010
```Hi,
It was pointed out to me in another thread that a Goertzel filter is pretty
much a very narrow bandpass filter that is run for a finite amount of time.
This does make sense after looking more closely at the math.

However, the neat thing about Goertzel is that the output is directly the
coefficient of the wanted DFT bin. The 'power' or 'amplitude' of the tone
can even be obtained without doing the final complex multiply.

How would I go about calculating the power/amplitude of a tone from the
output of a bandpass filter? It seems like more math would be required
unless I'm missing a simple trick.

Thanks!
```
```On Mar 25, 8:31&#2013266080;am, "gretzteam" <gretzteam@n_o_s_p_a_m.yahoo.com>
wrote:
> Hi,
> It was pointed out to me in another thread that a Goertzel filter is pretty
> much a very narrow bandpass filter that is run for a finite amount of time.
> This does make sense after looking more closely at the math.
>
> However, the neat thing about Goertzel is that the output is directly the
> coefficient of the wanted DFT bin. The 'power' or 'amplitude' of the tone
> can even be obtained without doing the final complex multiply.
>
> How would I go about calculating the power/amplitude of a tone from the
> output of a bandpass filter? It seems like more math would be required
> unless I'm missing a simple trick.
>
> Thanks!

You said it yourself: the Goertzel algorithm is just a way to
implement a simple BPF (a boxcar) that is placed arbitrarily in the
frequency band. The squared magnitude of the complex numbers that you
get out are proportional to the total signal power in the bandwidth of
the BPF. If you expect that the power inside that bandwidth is due to
a tone, then the magnitude of the BPF output would be proportional to
the tone amplitude.

Jason
```
```>You said it yourself: the Goertzel algorithm is just a way to
>implement a simple BPF (a boxcar) that is placed arbitrarily in the
>frequency band. The squared magnitude of the complex numbers that you
>get out are proportional to the total signal power in the bandwidth of
>the BPF. If you expect that the power inside that bandwidth is due to
>a tone, then the magnitude of the BPF output would be proportional to
>the tone amplitude.
>
>Jason

Hi,
I'm actually expecting a tone, so this all makes sense. The max amplitude
of the BPF output should somewhat match the Goertzel algorithm output (up
to some precision depending on N etc...).

Now where I'm confused is that I need to detect this 'amplitude' out of the
BPF. Should this simply be a peak-and-hold detect? Or should I average say
the last 5 peak values? I'm sure this all means something slightly
different and is also maybe related to the N in Goertzel algorithm? I just
can't see it.

Thanks!

```
```How do you numerical evaluate the Goertzel output? There must be some a
mathematical breakdown of the output value linked to gain that can be used?
If you are doing progressive comparisons how tight do you make the
threshold checks?

How do you compare the magnitude output of two different Goertzel windows
of different N?

```
```
djc-mrxtech wrote:

> How do you numerical evaluate the Goertzel output? There must be some a
> mathematical breakdown of the output value linked to gain that can be used?
> If you are doing progressive comparisons how tight do you make the
> threshold checks?
>
> How do you compare the magnitude output of two different Goertzel windows
> of different N?
>
>
```
```On Wed, 26 Oct 2011 09:52:16 -0500, djc-mrxtech wrote:

> How do you numerical evaluate the Goertzel output?

To what purpose do you want to evaluate the output?  Knowing where you
want to be goes a long way to knowing how to get there.

> There must be some a
> mathematical breakdown of the output value linked to gain that can be
> used?

I'm guessing that you want an unbiased measure of the signal amplitude at
the filter design frequency.  If so, then yes there is.  It depends both
on the structure of your particular filter and on the amount of time you
run it.

> If you are doing progressive comparisons how tight do you make the
> threshold checks?

That depends on your expected signal amplitude, whether you know the
signal phase, the expected deviation of the signal frequency from ideal,
the amount of noise, and probably a bazillion other things that are
specific to your application that I haven't thought of.

> How do you compare the magnitude output of two different Goertzel
> windows of different N?

If you mean how do you compare the magnitude output of two different
Goertzel filters that are otherwise identical but have been run for
different numbers of samples, then the answer is that for a signal that's
spot-on the correct frequency, there'll be a gain difference of N1/N2,
where N1 and N2 are the sample lengths going into the two different
filters.

If that's not what you meant, you should clarify.

--
www.wescottdesign.com
```