You are on page 1of 24

# Lectures 20-21 EE-802 ADSP SEECS-NUST

Processing
Dr. Amir A. Khan
Office : A-218, SEECS
9085-2162; amir.ali@seecs.edu.pk
Lecture Outline
Wrap-up of Last Lecture
Linear Filtering Approach to Computation
of DFT
Total computations
N/2.log
2
N
i/p
Indx
b
2
b
1
b
0
b
2
' b
1
' b
0
'
Bit-reversed order
Input placement
x 0 0 0 0 0 0 0
0
x 1 0 0 1 1 0 0
4
x 2 0 1 0 0 1 0
2
x 3 0 1 1 1 1 0
6
x 4 1 0 0 0 0 1
1
x 5 1 0 1 1 0 1
5
x 6 1 1 0 0 1 1
3
x 7 1 1 1 1 1 1
7
x goes in location 0; x goes in location 4; x goes in location 3,
A = a + W
N
r
b
B = a - W
N
r
b
Once (a,b) are used to calculate (A,B), there is no need for (a,b)
Hence (A,B) results can be saved in the same memory location as (a,b)
resulting in efficient memory utilization and the name in-place computation
2N memory registers required
Condition : inputs (sequence) /outputs (DFT coefficients) be stored in bit-
reversed order
a
b
Direct DFT vs FFT Round-up
Understanding DSP (Lyons)
Understanding DSP (Lyons)
Chapter 4 (Section 4.2: Hints on using FFTs in Practice)
*
Other FFT Algorithms
Other DFT algorithms (Discussion in Next lecture)
Goertzel Algorithm (Tone-detector)
Chirp Transform Algorithm
* Highly recommended
Linear Filtering/Convolution Approach to
Computation of Fourier Transform
The Geortzel Algorithm (Oppenheim)

The Chirp-Transform Algorithm (Oppenheim)
The Goertzel Algorithm
Suitable if a particular frequency or a small number of
frequencies need to be detected
Algorithm exploits periodicity of phase factors

Express computation of DFT as a linear filtering operation

Define

Using x[n]=0 for n<0 and n>N-1, DFT can be calculated as

( )
1
2 / 2
= = =

k j Nk N j
kN
N
e e W
t t
| |
( )

=

=
= = =
1
0
1
0
1
0
] [ ] [ ] [
N
r
r N k
N
N
r
kr
N
kN
N
N
r
kr
N
W r x W r x W W r x k X
| |
( )
| |

=

=
r
r n k
N k
r n u W r x n y ] [
| | | |
N n
k
n y k X
=
=
The Goertzel Algorithm

Represents a system with impulse response

System Function

First-order Goertzel system

Complexity
4N real multiplications and 4N real additions required for one X[k]
Direct method requires 4N real multiplication & 4N-2 real additions
Less Efficient than Direct Method
| | | | n u W n h
kn
N

=
| |
( )
| |

=

=
r
r n k
N k
r n u W r x n y ] [ | | | |
N n
k
n y k X
=
=
( )
1
1
1

=
z W
z H
k
N
k
| | | | 1 ] [ + =

n y W n x n y
k
k
N k
The Goertzel Algorithm-Complexity Reduction
First-order Goertzel system function

Multiply both numerator and denominator by a factor

Second order Goertzel Filter

( )
1
1
1

=
z W
z H
k
N
k
| | | |
N n
k
n y k X
=
=
( )
( )( ) 2 1
1
1 1
1
2
cos 2 1
1

1 1
1

+

=

=
z z
N
k
z W
z W z W
z W
z H
k
N
k
N
k
N
k
N
k
t
v
k
[n]
| | | | | | | | n x n v n v
N
k
n v
k k k
+
|
.
|

\
|
= 2 1
2
cos 2
t
| | | | | | 1 ] [ = =
=
N v W N v n y k X
k
k
N k
N n
k
The Goertzel Algorithm-Complexity Reduction
Complexity
Real multiplications for poles
2 per input sample
4 per input sample
Where do we gain then?
Implementation of zeros
1 complex mult. at Nth iter.
4 real multiplications

Total Complexity
Poles+Zeros
2N+4 = 2(N+2) real multiplications

Multiplications reduced by half as compared to Direct Computation
v
k
[n]
| | | | | | | | n x n v n v
N
k
n v
k k k
+
|
.
|

\
|
= 2 1
2
cos 2
t
| | | | | | 1 ] [ = =
=
N v W N v n y k X
k
k
N k
N n
k
Single Tone Detection Example (Lyons)
Tone Detector
To detect 30 KHz tone.
Assume Sampling Frequency f
s
= 128KHz
N = 64 point FFT
Solution
k = f
tone
/N f
s
= 15
2Cos (2tk/N) = 0.196
-exp(-j2tk/N)=-0.098 + j 0.995
DTMF Tone Detection-Goertzel Algorithm
Dual-Tone Multi Frequency (DTMF) signaling system uses a
combination of two tones to represent a specific digit, character or
symbol

1 2 3
6 5 4
7 8 9
# 0 *
A
B
C
D
1209Hz 1336Hz 1477Hz 1633Hz
697Hz
770Hz
852Hz
941Hz
1 2 3
6 5 4
7 8 9
# 0 *
A
B
C
D
1336 770 770 770 770 1336 1336 1336
O
u
t
p
u
t

DTMF Tone Detection-Goertzel Algorithm
For tone detection, use either a filter bank (band-pass filters) or Goertzel
algorithm (more efficient)
Determine the value of k for using Goertzel Algorithm

Minimum DTMF tone duration required is 40 ms, with a sampling rate of
8kHz results in 0.04 x 8000 = 320 samples
Standard DTMF number of samples in input tone, N = 205

N
kf
f
s
=
analysis
N
f
f
k
s
tone
=
Frequency k
1633 42
1477 38
1336 34
1209 31
941 24
852 22
770 20
697 18
Feed-back (pole) section would be repeated N=205 times
Evaluation of Goertzel algorithm zero equation at k bins
For detecting presence/absence of tone, we detect only
the magnitude of the filter output (ignore the phase)

| | | | | | | | n x n v n v
N
k
n v
k k k
+
|
.
|

\
|
= 2 1
2
cos 2
t
| | | | | | 1 ] [ = =
=
N v W N v n y k X
k
k
N k
N n
k
Chirp Transform Algorithm
Frequency resolution of FFT?
Same as that of DFT = 2t/N, with N the length of the input sequence.
What should we do if resolution is not sufficient enough for a
given application?
may increase the complexity unnecessarily
Practically increased resolution is required only for a certain band
of frequencies
Assume we need to determine the frequency of a sinusoid e
0
with
good accuracy from a given N point sequence
Compute DFT only around the frequency bins susceptible to
capture e
0
Chirp transform does exactly this job to compute DFT in a
zoomed region
Chirp Transform Algorithm
Algorithm does not reduce the computational complexity over FFT
But, allows computing DTFT over any equally spaced finite set of
frequencies
Consider x[n], an N point sequence with DTFT X(e
j
)
Evaluate M samples of X(e
je
) equally spaced in frequency on the
unit circle at frequencies

Results in DFT when
e = 0 and M = N

k
=
0
+ k
where k=0,1,.M-1
= 2tk/M
Chirp Transform Algorithm
DTFT is sampled at e = e
k

Defining W as

Chirp transform represents X(e
jek
) as a convolution
By substituting

Defining
Chirp Transform Algorithm

Re-formulating for easier interpretation as convolution

Convolution of g[n] with W
-n/2

Complex exponential with frequency nAe
Linearly increasing frequency signal called chirp used extensively in radars/sonars
Chirp Transform Algorithm-FIR form

Assuming that g[n] is of finite duration
W is an infinite duration exponential
For above equation
Finite portion of W
-n
is used for conv
Over interval n=0 M-1
Portion of W
-n
required is
-(N-1) to M-1
Defining an FIR filter

N = M condition is not required as in FFT
Neither N nor M needs to be a composite number (they can
be prime numbers)
Parameter
0
is arbitrary, thus providing flexibility
The convolution sum involved in chirp transform can be
implemented efficiently using FFT with a size
M+N-1
Chirp Transform with Causal FIR filter
Non-causal
Causal
Delay h[n] by N-1 samples
The Fourier Transform is thus advancing the output by N-1
Chirp Transform Algorithm - Example
Example: Suppose we have a finite length sequence x[n] that is
non-zero over the interval n=0,,25 and we wish to compute
16 samples of DFT (X
ej
) at frequencies
k
= 2/27 +
2k/1024 for k = 0,,15
Solution
Let M = 16 and N = 26,
0
= 2/27 and = 2t/1024
For the Causal Impulse Response
h[n] = [e
-j2t/1024
]
(n-25)/2
for n=0,.40 (n= 0 to N+M-2)
Output y[n] will be samples beginning at index n+25
y[n+25] = X(e
jen
)|
en = 2t/27 + 2tn/1024