Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

The Goertzel algorithm is derived from the Discrete Fourier Transform (DFT) and exploits the

2πk
−j
N
periodicity of the phase factor e to reduce the computational complexity associated with the DFT
as the Fast Fourier Transform (FFT) does. However the Goertzel algorithm is more efficient than the
FFT, when only a few samples of the DFT are required. With the Goertzel algorithm only 16 samples
of the DFT are required. The Goertzel algorithm can be derived as follows using the DFT equation.

N −1 2πkn
−j
X (k ) = ∑ x(n )e N

n =0
[1]
2πkN N −1 2πkn 2πkN
−j
∑ x(n)e
j j
=e N N
; (e N
= 1)
n =0

X (k ) can be written as:

N −1
X (k ) = ∑ x(n )hk ( N − n )
n=0
2πk
−j (n − N )
where: hk ( N − n ) = e N
.

X (k ) can now be identified as an output of a filter at m = N and the filter can be written as follows:

N −1
y k (m ) = ∑ x(n )hk (m − n ) . [2]
n=0

Therefore:

X k ( N ) = y k (m ) m = N [3]

This can be read as: the Discrete Fourier Transform X k (N ) is the output of the filter y k (m ) at
m=N.

The z-transform of y k , y k ( z ) is given by:

X (z )
y k (z ) = 2πk
. [4]
j
1− e N
z −1
Deriving the difference equation,

2πk

y k (n ) = x(n ) + e y k (n − 1); y k (− 1) = 0 .
j
N
[5]

This can be implemented as a single pole IIR filter as shown in Figure 8.2.
x(n) y(n)
+

z -1

2πk
j
e N

Figure 8.2 Structure of a Single Pole Resonator for computing the DFT

Equation [5] involves multiplication by a complex number and each complex multiplication results in
four real multiplications and four real additions.

To avoid complex multiplication, Equation [4] is multiplied by a complex conjugate pole and simplified
as follows:


 −j 
X ( z )1 − e N z −1 
k

y k (z ) =  
2π 2π
 j k  −j k 
1 − e N z −1 1 − e N z −1 
  
  

 −j k 
1 − e N z −1 
 
= X (z )  
( )(
1 − z (cosθ + j sin θ ) 1 − z (cosθ − j sin θ )
−1 −1
)

 −j k 
1 − e N
z −1 

= X (z )   . [6]
 2π  −1 −2
1 − 2 cos k z + z
 N 

Equation [6] can be implemented using the structure shown in Figure 8.3.

x(n) Qn y (n )
+ +

z −1
Qn −1 2π
+  2π  −j k
2 cos
N 
k
−e N

z −1

Qn − 2
-1

th
Figure 8.3 Structure of a two Pole Resonator for Computing the k DFT sample

where
 2πk 
Qn = x(n ) + 2 cos Qn −1 − Qn − 2 [7]
 N 
and

−j
y k (n ) = Qn − Qn −1e
k
N
[8]
or X k ( N ) = y k (m ) m = N .

This means that y k (n ) need not be calculated for every value of m as it only needs to be calculated
at m = N .

Finally Equations [7] and [8] can be rewritten as follows:

 2πk 
Qn = x(n ) + 2 cos Qn −1 − Qn − 2 ; 0≤n≤ N [9]
 N 
and

−j
y k (n ) n = N = X (k ) = Q N − Q N −1e
k
N
; n=N. [10]

With this modified structure there is only one complex multiplication for the calculation of each X (k ) .
To implement this algorithm the feedback stage has to be repeated N times and the feedforward stage
to be done once only. Since with DTMF detection we are not interested in the phase information, the
Goertzel algorithm maybe modified to produce an output which is proportional to the magnitude of the
signal. This has the advantage of using only real coefficients and minimising processing time as
shown below.


−j
y k (N ) = QN − e
k
N
Q N −1
− jθ
= A − Be
= [ A − B cosθ ] + jB sin θ ,
where: A = Qn
B = Qn −1
2πk
θ= .
N
The square of the magnitude is:

y k (n ) = ( A − B cos θ ) + (B sin θ )
2 2 2

= A 2 − 2 AB cos θ + B 2 cos 2 θ + B 2 sin 2 θ


= A 2 + B 2 − 2 AB cos θ
Therefore:

 2πk 
y k ( N ) = X (k ) = Q 2 ( N ) + Q 2 ( N − 1) − 2 cos Q( N )Q( N − 1) .
2 2
[11]
 N 

X (k ) requires only real additions and multiplications.


2
Equation [11] shows that the calculation of

You might also like