# How can I find the amplitude of the 20 Hz frequency component of a signal faster?

I have a time varying discrete signal x(t) sampled at 5ms rate. I need to find the amplitude of the 20 Hz frequency component for each sample. What I do today is that for each sample I do a Short-time Fourier Transform of the data in a window around that sample. Then I read the amplitude for the 20 Hz frequency component off the amplitude spectrum. This seems to work fine, but it is slow.

How can I speed up this process? For instance I am only interested in the 20 Hz component. Is there some way I can avoid finding the complete amplitude spectrum (that is faster than FFT)?

• en.wikipedia.org/wiki/Goertzel_algorithm Commented Mar 13, 2013 at 9:48
• Thanks pichenettes! This looks exactly like what I am looking for.
– Andy
Commented Mar 13, 2013 at 10:24

As pichenettes already pointed out in a comment above, one approach is to use the Goertzel algorithm. However, it is a somewhat common misconception that in order to deduce the amplitude of various frequency bands in a signal, one must use Fourier-transform-based techniques. There are other methods that may be more appropriate to your application.

In your case, for example, you would do equally well by just creating any bandpass filter centered at 20 Hz and watching the amplitude of its output over time. The DFT (and by extension the Goertzel algorithm) can be viewed as just a bank of equally-spaced, critically-sampled bandpass filters. If you only need one output, then a DFT is overkill, and the Goertzel algorithm can be limiting, as you don't have much control over its frequency response about 20 Hz.

• Hi, I'm in the same situation as the asker, but I'm not sure how to use the filter, if I filter the signal with a very narrow bandpass, I'll get a sine wave, how do I get an amplitude? do I have to do an RMS of the filtered signal? Commented May 8, 2016 at 10:32