https://en.wikipedia.org/wiki/Goertzel_algorithm
Many applications require the detection of a few discrete sinusoids. The Goertzel filter is an IIR filter that uses the feedback to generate a very high Q bandpass filter where the coefficients are easily generated from the required centre frequency, according to the following equations. The most common configuration for using this technique is to measure the signal energy before and after the filter and to compare the two. If the energies are similar then the input signal is centred in the pass-band, if the output energy is significantly lower than the input energy then the signal is outside the pass band. The Goertzel algorithm is most commonly implemented as a second order recursive IIR filter, as shown below.
Matlab Code
function Xk = goertzel_non_integer_k(x,k)
% Computes an N-point DFT coefficient for a
% real-valued input sequence 'x' where the center
% frequency of the DFT bin is k/N radians/sample.
% N is the length of the input sequence 'x'.
% Positive-valued frequency index 'k' need not be
% an integer but must be in the range of 0 –to- N-1.
% [Richard Lyons, Oct. 2013]
N = length(x);
Alpha = 2*pi*k/N;
Beta = 2*pi*k*(N-1)/N;
% Precompute network coefficients
Two_cos_Alpha = 2*cos(Alpha);
a = cos(Beta);
b = -sin(Beta);
c = sin(Alpha)*sin(Beta) -cos(Alpha)*cos(Beta);
d = sin(2*pi*k);
% Init. delay line contents
w1 = 0;
w2 = 0;
for n = 1:N % Start the N-sample feedback looping
w0 = x(n) + Two_cos_Alpha*w1 -w2;
% Delay line data shifting
w2 = w1;
w1 = w0;
end
Xk = w1*a + w2*c + j*(w1*b +w2*d);
Quiet Beacon
Low-powered beacon transmitter/receiver which can be used either on its own or in addition to libquiet. The transmitter creates a simple sine tone at a specified frequency, and the receiver uses the '''Goertzel Algorithm''' to detect the presence of the tone with complexity O(n) for n samples.