Professional Documents
Culture Documents
Digital Speech Processing-: Review of DSP Fundamentals
Digital Speech Processing-: Review of DSP Fundamentals
Lecture 2
Review of DSP
Fundamentals
1
What is DSP?
Input Output
Signal Analog-to- Digital-to- Signal
Digital Computer Analog
Conversion Conversion
Digital
• Method to represent a quantity, a phenomenon or an event
• Why digital?
Signal
• What is a signal?
– something (e.g., a sound, gesture, or object) that carries information
– a detectable physical quantity (e.g., a voltage, current, or magnetic field strength) by
which messages or information can be transmitted
• What are we interested in, particularly when the signal is speech?
Processing
• What kind of processing do we need and encounter almost
everyday?
• Special effects?
2
Common Forms of Computing
• Text processing – handling of text, tables, basic
arithmetic and logic operations (i.e., calculator
functions)
– Word processing
– Language processing
– Spreadsheet processing
– Presentation processing
• Signal Processing – a more general form of
information processing, including handling of speech,
audio, image, video, etc.
– Filtering/spectral analysis
– Analysis, recognition, synthesis and coding of real world signals
– Detection and estimation of signals in the presence of noise or
interference
3
Advantages of Digital Representations
Input Output
Signal A-to-D Signal D-to-A Signal
Converter Processor Converter
4
Digital Processing of Analog Signals
xc(t) x[n] y[n] yc(t)
A-to-D Computer D-to-A
plot( );
stem( );
7
Varying Sampling Rates
Fs=8000 Hz
Fs=6000 Hz
Fs=10000 Hz
8
Varying Sampling Rates
Fs=8000 Hz
Fs=6000 Hz
Fs=10000 Hz
9
Quantization
x[n] can be quantized to one of a finite set of values which is
then represented digitally in bits, hence a truly digital signal; the
course material mostly deals with discrete-time signals
(discrete-value only when noted).
out
Quantization:
sample 4
Sampled quantize
Sinusoid
2
5sin(2πnT)
0
y
6
6
-2
4
Analog Discrete
sinusoid, -4
4
sinusoid
2
5sin(2πx) -6
2 round[5sin(2πnT)]
0 5 10 15 20 25 30 35 40
0 n
y
y
-2 6
-2
Quantized
-4 4
sinusoid -4
-6 2 round[5sin(2πx)]
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 -6
0 5 10 15 20 25 30 35 40
x
0
n
y
-2
quantize -4
sample
-6
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
x
11
Sinewave Spectrum
12
Issues with Discrete Signals
• what sampling rate is appropriate
– 6.4 kHz (telephone bandwidth), 8 kHz (extended
telephone BW), 10 kHz (extended bandwidth), 16 kHz
(hi-fi speech)
• how many quantization levels are necessary at
each bit rate (bits/sample)
– 16, 12, 8, … => ultimately determines the S/N ratio of
the speech
– speech coding is concerned with answering this
question in an optimal manner
13
The Sampling Theorem
Sampled 1000 Hz and 7000 Hz Cosine Waves; Fs = 8000 Hz
1
0.5
amplitude
0
-0.5
-1
15
Maple Rag: 16 bits, 12 bits, 10 bits, 8 bits, 6 bits, 4 bits;
Noise: 10 12 bits
Discrete-Time (DT) Signals are Sequences
16
Impulse Representation of Sequences
∞ Value of the
A sequence,
x[ n ] = ∑ x[k ]δ [n − k ]
k =−∞
function at k
a function
a1δ [n − 1]
a−3δ [n + 3]
a2δ [n − 2] a7δ [n − 7]
⎧1, n ≥ 0
unit step u[n] = ⎨ sine wave x[n] = A cos(ω 0 n + φ )
⎩0, n < 0
18
Variants on Discrete-Time Step Function
u[n] u[n-n0]
u[n0-n]
20
Complex Signal
x [n ] = (α + j β )n u[n ] = (re jθ )n u[n ]
r = α +β 2 2
θ = tan ( β / α )
−1
β r
θ
α
jθ n
x [n ] = r e n
u[n ]
r n is a dying exponential
jθ n
e is a linear phase term
21
Complex DT Sinusoid
x [n ] = A e jω n
• Frequency ω is in radians (per sample), or just
radians
– once sampled, x[n] is a sequence that relates to
time only through the sampling period T
• Important property: periodic in ω with period 2π:
jω 0n j (ω 0 + 2 π r )n
Ae = Ae
– Only unique frequencies are 0 to 2π (or –π to +π)
– Same applies to real sinusoids
22
Sampled Speech Waveform
xa(t)
MATLAB: plot
x[n]
xa(nT),x(n)
MATLAB: stem
24
LTI Discrete-Time Systems
x[n] y[n]
LTI
System
δ [n] h[n]
• Linearity (superposition):
Τ{ax1[n] + bx2 [n]} = aΤ {x1[n]} + bΤ {x2 [n]}
• Time-Invariance (shift-invariance):
x1[n] = x[n − nd ] ⇒ y1[n] = y[n − nd ]
⎧ n
⎪ ∑ 1⋅ 1 = (n + 1) 0≤n≤3 y[n]
⎪ m =0
⎪ 3
= ⎨ ∑ 1⋅ 1 = (7 − n ) 4≤n≤6
⎪ m = n −3
⎪0 n ≤ 0, n ≥ 7 01234 567
n
⎪
⎩
27
h[n] x[n]
n n
01234 5 01234 5
n=0 n=1 n=2
m m m
01234 5 01234 5 01234 5
n=3 n=4 n=5
m m m
01234 5 01234 5 01234 5
n=6 n=7 n=8
m m m
01234 56 01234 567 01234 5678
28
Convolution Example
The impulse response of an LTI system is of the form:
h[n ] = a n u[n ] | a |< 1
and the input to the system is of the form:
x [n ] = b n u[n ] | b |< 1, b ≠ a
Determine the output of the system using the formula
for discrete convolution.
SOLUTION:
∞
y [n ] = ∑
m =−∞
a m u [m ] b n − m u [n − m ]
n n
=b n
∑a
m =0
m
b −m
u[n ] = b n
∑ (a / b )
m =0
m
u[n ]
⎡1 − (a / b )n +1 ⎤ ⎡ b n +1 − a n +1 ⎤
=b ⎢ n
⎥=⎢ ⎥ u[n ]
⎣ 1 − (a / b ) ⎦ ⎣ b − a ⎦
29
Convolution Example
30
Convolution Example
Consider a digital system with input x[n ] = 1 for
n = 0,1,2,3 and 0 everywhere else, and with impulse
response h[n ] = a n u[n ], | a |< 1. Determine the
response y [n ] of this linear system.
SOLUTION:
We recognize that x [n ] can be written as the difference between two
step functions, i.e., x [n ] = u[n ] − u[n − 4]. Hence we can solve for y [n ]
as the difference between the output of the linear system with a step input
and the output of the linear system with a delayed step input. Thus we solve
for the response to a unit step as:
∞
⎡ a n − a −1 ⎤
y 1[ n ] = ∑ u [ m ] a u [ n − m ] = ⎢
n −m
−1 ⎥
u[n ]
m =−∞ ⎣ 1− a ⎦
y [n ] = y1[n ] − y1[n − 4] 31
Linear Time-Invariant Systems
• easiest to understand
• easiest to manipulate
• powerful processing capabilities
• characterized completely by their response to unit sample,
h(n), via convolution relationship
∞ ∞
y [n ] = x[n ] ∗ h[n ] = ∑ x[k ] h[n − k ] = ∑ h[k ] x[n − k ]
k =−∞ k =−∞
x2[n]
x[n] x[n-1]
D is a delay of 1-sample
Can replace D with delay element z −1 33
Equivalent LTI Systems
h1[n] h2[n] h1[n]
x[n] y[n]
x[n] y[n]
h2[n]
h2[n] h1[n]
x[n] y[n]
h1[n]+h2[n]
x[n] y[n]
h1[n]*h2[n]
x[n] y[n]
34
More Complex Filter Interconnections
h2[n]
h1[n]
h3[n]
h4[n]
y [n ] = x [n ] * hc [n ]
hc [n ] = h1[n ] * (h2 [n ] + h3 [n ]) + h4 [n ]
35
Network View of Filtering (FIR Filter)
x[n] y[n]
D (Delay Element) ⇔ z −1
y [n ] = b0 x [n ] + b1x[n − 1] + ... + bM −1x [n − M + 1] + bM x [n − M ]
36
Network View of Filtering (IIR Filter)
x[n] y[n]
y [n ] = −a1y [n − 1] + b0 x [n ] + b1x [n − 1]
37
z-Transform
Representations
38
Transform Representations
• z-transform: infinite power series in z ,
−1
x[n ] ←⎯
→ X (z) with x[n] as coefficients of
−n
term in z
∞
X (z) = ∑
n =−∞
x[n ]z − n • direct evaluation using residue theorem
• partial fraction expansion of X(z)
1
∫
• long division
x[n ] = X (z )z n −1dz
2π j C
• power series expansion
∑ | x
n =−∞
[ n ] | | z −n
|<∞ - sufficient condition for convergence
0.9
0.7
0.6
plitude
0.5
am
0.4
− n0
X (z) = z − − converges for | z |> 0, n0 > 0;
0.3
0.2
0.1
0
0 1 2 3 4 5 6 7 8 9
sample number
0.9
0.8
0.7
−N
N -1
1− z
0.6
X(z) = ∑ (1)z − n =
amplitude
-- converges for 0 <| z |< ∞
0.5
0.4
−1
0.3
1− z
0.2
n =0
0.1
0
0 1 2 3 4 5 6 7 8 9
sample number
∞
1
0.9
X (z) = ∑ a z =
0.8
−n
n
--converges for | a |<| z |
0.7
0.6
−1
1 − az
amplitude
0.5
n =0
0.4
0.3
0.1
0
0 5 10 15 20 25 30 35 40 45 50
sample number
40
Examples of Convergence Regions 0
-0.1
-0.2
-0.3
-0.4
amplitude
-0.5
-0.6
-0.7
-0.8
4. x[n ] = −b u[−n − 1]
n -0.9
-1
-50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0
sample number
−1
1
X (z) = ∑
n =−∞
−b n z − n =
1 − bz −1
--converges for | z |<| b |
∞ ∞
Y (z) = ∑
n =−∞
y [ n ]z −n
= ∑
n =−∞
a n x [n ]z − n
∞
= ∑
n =−∞
x [n ]( z / a )− n = X ( z / a )
∞
dX ( z )
= − ∑ nx [n ]z − n −1
dz n =−∞
1 ∞
= − ∑ nx [n ]z − n
z n =−∞
1
= − Z (nx [n ])
z
43
Inverse z-Transform
1
x[n ] =
2π j ∫
C
X (z )z n −1dz
45
Example of Partial Fractions
z2 + z + 1
Find the inverse z-transform of H (z ) = 2 1 <| z |< 2
(z + 3z + 2)
H (z) z2 + z + 1 A0 A1 A2
= = + +
z z (z + 1)(z + 2) z z + 1 z + 2
z2 + z + 1 1 z2 + z + 1
A0 = = A1 = = −1
(z + 1)(z + 2) z =0 2 z (z + 2) z =−1
z2 + z + 1 3
A2 = =
z (z + 1) z =−2 2
1 z (3 / 2)z
H (z) = − + 1 <| z |< 2
2 z +1 z + 2
1 3
h[n ] = δ [n ] − (−1)n u[n ] − (−2)n u[−n − 1]
2 2
46
Transform Properties
Linearity ax1[n]+bx2[n] aX1(z)+bX2(z)
Shift x[n-n0] z − n0 X (z )
Exponential Weighting anx[n] X(a-1z)
Linear Weighting n x[n] -z dX(z)/dz
Time Reversal x[-n] non-causal, need x[N0-n] to be
causal for finite length sequence X(z-1)
Convolution x[n] * h[n] X(z) H(z)
Multiplication of x[n] w[n] 1
2π j ∫ X (v )W (z / v )v −1dv
Sequences C circular convolution in the frequency
domain
47
Discrete-
Time Fourier
Transform
(DTFT)
48
Discrete-Time Fourier Transform
∞
X (e jω ) = X (z ) |z =e jω = ∑
n =−∞
x[n ]e − jωn
jω
z = e ; | z |= 1, arg(z ) = jω
π
1
x[n ] =
2π −
∫π X (e jω )e jωn dω
∑ |
n =−∞
x [ n ] | | z −n
|= ∑ | x[n] |< ∞, since
n =−∞
| z |= 1
49
Simple DTFTs
jω
Impulse x [n ] = δ [n ], X (e ) = 1
Delayed
impulse
x [n ] = δ [n − n0 ], X (e jω ) = e − jωn0
jω 1
Step function
x [n ] = u[n ], X (e ) =
1 − e − jω
− j ωN
jω 1− e
Rectangular
x [n ] = u[n ] − u[n − N ], X (e ) = − jω
1− e
window
jω 1
Exponential x [n ] = a u[n ],
n
X (e ) = − jω
, a <1
1 − ae
jω 1
x [n ] = −b u[ −n − 1], X (e ) = , b >1
Backward n
exponential
− jω
1 − be 50
DTFT Examples
x[n ] = β nu[n ] β = 0.9
1
jω
X (e ) = | β |< 1
1− βe − jω
51
DTFT Examples
x [n ] = cos(ω0 n ), −∞ < n < ∞
∞
X (e j ω ) = ∑ [πδ (ω − ω
k =−∞
0 + 2π k ) + πδ (ω + ω0 + 2π k )]
x [n ] = cos(ω0 n )
52
DTFT Examples
x [n ] = rect M [n ]
53
DTFT Examples
h[n ]
54
Fourier Transform Properties
0.25, π/2, FS/ 4, π FS/ 2
• periodicity in ω
0. 5, π, FS/ 2, π FS
0,0,0,0
1, 2π, FS, 2π FS
jω j ( ω + 2π n )
X (e ) = X (e ) f, ω, f 0.75, 3π/2, 3FS/ 4, π 3FS/ 2 D, ωD
Solution:
If the signal is periodic with period N , then we have:
x[n ] = x[n + N ]
cos(2π ⋅ 100n / Fs ) = cos(2π ⋅ 100( n + N ) / Fs )
2π ⋅ 100 N
= 2π ⋅ k ( k an integer )
Fs
100 N 100 N
k= =
Fs 11,059
11059
For k an integer we get N = k which is not an integer
100
Thus x[n ] is not periodic at this sampling rate. 58
Periodic DT Signals
Example 3:
Fs = 10, 000 Hz
Is the signal x[n] = cos(2π ⋅101n / Fs ) a periodic signal?
If so, what is the period.
Solution:
If the signal is periodic with period N , then we have:
x[n] = x[n + N ]
cos(2π ⋅101n / Fs ) = cos(2π ⋅101(n + N ) / Fs )
2π ⋅101N
= 2π ⋅ k (k an integer )
Fs
101N 101N
k= = which is not an integer
Fs 10, 000
Thus x[n] is not periodic at this sampling rate.
59
Periodic Sequences??
60
The DFT – Discrete
Fourier Transform
61
Discrete Fourier Transform
• consider a periodic signal with period N (samples)
x%[n ] = x%[n + N ], − ∞ < n < ∞
x%[n ] can be represented exactly by a discrete
sum of sinusoids
N −1
X% [k ] = ∑ x%[n ]e − j 2π kn / N
• N sequence values
n =0
1 N −1 %
x%[n ] = ∑ X [k ]e j 2π kn / N • N DFT coefficients
N k =0
• exact representation of the discrete periodic sequence 62
DFT Unit Vectors (N=8)
k = 0; e − j 2π k /8 = 1
2
k = 1; e − j 2π k /8 = (1 − j )
2
k = 2; e − j 2π k /8 = −j
2
k = 3; e − j 2π k /8 = (−1 − j )
2
k = 4; e − j 2π k /8 = −1
2
k = 5; e − j 2π k /8 = (−1 + j )
2
k = 6; e − j 2π k /8 = j
2
k = 7; e − j 2π k /8 = (1 + j )
2
63
DFT Examples
δ [ n] DFT{δ [n]}
1 1
n k
64
DFT Examples
x[n] X [k]
65
DFT Examples
x%[n ] = (0.9)n 0 ≤ n ≤ 31 (N = 32)
66
Circularly Shifting Sequences
x[n-2] x((n-2))
x[n]
67
Review
DTFT of sequence { x[n ], − ∞ < n < ∞ }
∞
X (e jω ) = ∑
n =−∞
x [ n ] e − j ωn
1 π
2π ∫−π
jω j ωn
x[n ] = X (e ) e
69
Finite Length Sequences
• consider a finite length (but not periodic)
sequence, x[n], that is zero outside the interval
0 ≤ n ≤ N −1
N −1
X (z ) = ∑ x[n ]z − n
n =0
j 2π k / N N −1
X [k ]=X (e )= ∑ x[n ]e − j 2π kn /N , k =0,1,...,N −1
n =0
70
--looks like DFT of periodic sequence!
Relation to Periodic Sequence
-consider a periodic sequence, x% [n ], consisting of an infinite 1
0.9
0.7
0.6
amplitude
0.5
x% (n ) = ∑ x[ n + r N ]
0.4
0.3
0.2
r =−∞
0.1
0
0 2 4 6 8 10 12 14 16 18
sample number
of the form:
N −1
X [k ] = ∑ x[n ]e − j 2π nk / N , k = 0,1,..., N − 1 Works for both
n=0 finite sequence
and for periodic
1 N −1 j 2π kn / N , n = 0,1,..., N − 1 sequence
x[ n ] = ∑ X [k ]e
Nk =0
71
Periodic and Finite Length Sequences
~ ~
x[n] X[k]
periodic signal => line
spectrum in frequency
n k
x[n] X(ejω)
finite duration =>
continuous spectrum
n ω in frequency
72
Sampling in Frequency (Time Domain Aliasing)
Consider a finite duration sequence:
S(e jω )
x[n ] ≠ 0 for 0 ≤ n ≤ L − 1
i.e., an L − point sequence, with discrete time Fourier transform . . .
L −1
X (e jω ) = ∑ x[n] e − jωn 0 ≤ ω ≤ 2π
n =0 0 1 2 3 4 N-1 k
ω=2πk/N
Consider sampling the discrete time Fourier transform by
multiplying it by a signal that is defined as:
s[n]
N −1
S (e ) = ∑ δ [ω − 2π k / N ]
jω
. . . . . .
k =0
74
Time Domain Aliasing Example
Consider the finite duration sequence
4
x[n ] = ∑ (m + 1) δ [n − m] = δ [n ] + 2δ [n − 1] + 3δ [n − 2] + 4δ [n − 3] + 5δ [n − 4]
m =0
-2 -1 0 1 2 3 4 5 6 7 8 n
The discrete time Fourier transform of x[n ] is computed and sampled at N frequencies
around the unit circle. The resulting sampled Fourier transform is inverse
transformed back to the time domain. What is the resulting time domain signal, x%[n ],
(over the interval 0 ≤ n ≤ L − 1) for the cases N = 11, N = 5 and N = 4.
SOLUTION:
For the cases N = 11 and N = 5, we have no aliasing (since N ≥ L) and we get x%[n ] = x[n ]
over the interval 0 ≤ n ≤ L − 1. For the case N = 4, the n = 0 value is aliased, giving
x%[0] = 6 (as opposed to 1 for x[0]) with the remaining values unchanged.
75
DFT Properties
Periodic Sequence Finite Sequence
Period=N Length=N
Sequence defined for all n Sequence defined for n=0,1,…,N-1
DFT defined for all k DTFT defined for all ω
76
DFT Properties for Finite Sequences
• X[k], the DFT of the finite sequence x[n], can be
viewed as a sampled version of the z-transform
(or Fourier transform) of the finite sequence
(used to design finite length filters via frequency
sampling method)
• the DFT has properties very similar to those of
the z-transform and the Fourier transform
• the N values of X[k] can be computed very
efficiently (time proportional to N log N) using the
set of FFT methods
• DFT used in computing spectral estimates,
correlation functions, and in implementing digital
filters via convolutional methods
77
DFT Properties
N-point sequences N-point DFT
1 N −1
5. Multiplication x[ n ] w [ n ] ∑
N r =0
X [r ]W ([k − r ])N
78
Key Transform Properties
y [n ] = x1[n ] ∗ x2 [n ] ⇔ Y (e jω ) = X1(e jω ) ⋅ X 2 (e jω )
convolution multiplication
y [n ] = x1[n ] ⋅ x2 [n ] ⇔ Y (e jω ) = X1(e jω ) ⊗ X 2 (e jω )
multiplication circular convolution
1 M −1 1 M −1 j 2π nk / M
x2 [n ] = ∑ X 2 [k ] e j 2π nk / M
= ∑e sampling function
M k =0 M k =0 79
Sampling Function
x[n]
... ...
0 M 2M n
X [k]
...
0 1 2 3 4 5 M-1 k
0 2π 4π 6π (M-1)2π
ω M M M M
80
Summary of DSP-Part 1
• speech signals are inherently bandlimited => must
sample appropriately in time and amplitude
• LTI systems of most interest in speech processing; can
characterize them completely by impulse response, h(n)
• the z-transform and Fourier transform representations
enable us to efficiently process signals in both the time
and frequency domains
• both periodic and time-limited digital signals can be
represented in terms of their Discrete Fourier transforms
• sampling in time leads to aliasing in frequency; sampling
in frequency leads to aliasing in time => when
processing time-limited signals, must be careful to
sample in frequency at a sufficiently high rate to avoid
time-aliasing
81
Digital Filters
82
Digital Filters
• digital filter is a discrete-time linear, shift invariant
system with input-output relation:
∞
y [n ] = x[n ] ∗ h[n ] = ∑
m =−∞
x[m] h[n − m]
∑ | h[n] |< ∞
n =−∞
84
Digital Filter Implementation
• input and output satisfy linear difference equation of the
form:
N M
y [n ] − ∑ ak y [n − k ] = ∑ br x[n − r ]
k =1 r =0
k =1 r =0
N M
Y (z ) (1 − ∑ ak z ) = X (z)∑ br z − r
−k
k =1 r =0
M
Y (z) ∑ r
b z −r canonic form
showing poles
H (z ) = = r =0
X (z) N
and zeros
1 − ∑ ak z − k
k =1 85
Digital Filters
−1
• H(z) is a rational function in z
O
M
A∏ (1 − cr z −1 )
X
H (z ) = r =1
=> M zeros, N poles O X
N
∏ k )
(1 − d z −1
O
X
k =1 X
87
FIR Systems
• if ak=0, all k, then
M
y [n ] = ∑ br x[n − r ] = b0 x[n ] + b1 x[n − 1] + ... + bM x[n − M ] =>
r =0
1. h[n ] = bn 0 ≤ n ≤ M
=0 otherwise
M M −1
2. H (z ) = ∑ bn z −n
=> ∏ (1 − c m z −1 ) => M zeros
n =0 m =0
• linear phase filter => no signal dispersion because of non-linear phase =>
precise time alignment of events in signal
90
LPF Example Using RW
91
LPF Example Using RW
6. Kaiser w [n ] =
{
I0 β 1 − ((n − M / 2) / (M / 2)) 2 }
I 0 {β }
94
Common Windows (Frequency)
95
Window LPF Example
2π π
d
−
N=30
F=[0 0.4 0.5 1];
A=[1 1 0 0];
B=firpm(N,F,A)
figure,orient landscape;
stitle=sprintf('bandpass fir design,
N:%d,f: %4.2f %4.2f %4.2f %4.2f %4.2f
%4.2f',N,F);
n=0:N;
subplot(211),plot(n,B,'r','LineWidth',2);
axis tight,grid on,title(stitle);
xlabel('Time in Samples'),ylabel('Amplitude');
legend('Impulse Response');
subplot(212),plot(W/pi,20*log10(abs(H)),'b','LineWidth',2);
axis ([0 1 -60 0]), grid on;
xlabel('Normalized Frequency'),ylabel('Log Magnitude (dB)');
legend('Frequency Response'); 101
FIR Implementation
x[n] x[n − 1] x[n − 2] x[n − 3] x[n − M ]
y[n]
∑ r
b z −r
N
Ak
H (z) = r =0
=∑ −1
- partial fraction expansion
k =1 1 − d k z
N
1 − ∑ ak z − k
k =1
N
h[n ] = ∑ Ak (d k )n u[n ] - for causal systems
k =1
105
Butterworth Design
106
0 0.2 π 0.4 π 0.6 π 0.8 π π
Frequency
Chebyshev Type I Design
107
Chebyshev BPF Design
111
Matlab Elliptic Filter Design
• use ellip to design elliptic filter
– [B,A]=ellip(N,Rp,Rs,Wn)
– B=numerator polynomial—N+1 coefficients
– A=denominator polynomial—N+1 coefficients
– N=order of polynomial for both numerator and denominator
– Rp=maximum in-band (passband) approximation error (dB)
– Rs=out-of-band (stopband) ripple (dB)
– Wp=end of passband (normalized radian frequency)
• use filter to generate impulse response
– y=filter(B,A,x)
– y=filter impulse response
– x=filter input (impulse)
• use zplane to generate pole-zero plot
– zplane(B,A)
112
Matlab Elliptic Lowpass Filter
M=N=4
N M
y [n ] = ∑ ak y [n − k ] + ∑ br x[n − r ]
k =1 r =0
N
w [n ] = ∑ ak w [n − k ] + x[n ]
k =1
M
y [n ] = ∑ br w [n − r ]
r =0
114
IIR Filter Implementations
N
A∏ (1 − cr z −1 )
H (z) = N
r =1
- zeros at z = cr , poles at z = d k
∏ (1 − d z
k =1
k
−1
)
- since ak and br are real, poles and zeros occur in complex conjugate pairs =>
b0 k + b1k z −1 + b2 k z −2
K
⎡ N + 1⎤
H(z) = A∏ −1
, K = ⎢ 2 ⎥
k =1 1 − a1k z − a2 k z −2 ⎣ ⎦
- cascade of second order systems
Used in formant
synthesis
systems based
on ABS
methods
115
IIR Filter Implementations
K
c0 k + c1k z −1
H (z) = ∑ −1 −2
, parallel system
k =1 1 − a1k z − a2 k z
c01
Common form
for speech
a21
synthesizer
c02 implementation
a12 c12
116
DSP in Speech Processing
• filtering — speech coding, post filters, pre-filters, noise
reduction
• spectral analysis — vocoding, speech synthesis,
speech recognition, speaker recognition, speech
enhancement
• implementation structures — speech synthesis,
analysis-synthesis systems, audio encoding/decoding for
MP3 and AAC
• sampling rate conversion — audio, speech
– DAT — 48 kHz
– CD — 44.06 kHz
– Speech — 6, 8, 10, 16 kHz
– Cellular — TDMA, GSM, CDMA transcoding
117
Sampling of Waveforms
xa(t) Sampler and x[n],x(nT)
Quantizer
Period, T
xa(nT)
∫x
− j Ωt
xa (t ) ←⎯
→ X a ( j Ω) = a (t ) e dt
−∞
∞
x[n ] ←⎯
→ X (e j ΩT
)= ∑x
n =−∞
a (nT )e − j ΩnT
∞
1
X (e ) = ∑ X a ( j Ω + j 2π k / T )
j ΩT
T k =−∞
120
Sampling Theorem Interpretation
121
Sampling Rates
• FN = Nyquist frequency (highest frequency with
significant spectral level in signal)
• must sample at at least twice the Nyquist
frequency to prevent aliasing (frequency
overlap)
– telephone speech (300-3200 Hz) => FS=6400 Hz
– wideband speech (100-7200 Hz) => FS=14400 Hz
– audio signal (50-21000 Hz) => FS=42000 Hz
– AM broadcast (100-7500 Hz) => FS=15000 Hz
• can always sample at rates higher than twice the
Nyquist frequency (but that is wasteful of
processing)
122
Recovery from Sampled Signal
• If 1/T > 2 FN the Fourier transform of the sequence of samples is
proportional to the Fourier transform of the original signal in the
baseband, i.e.,
j ΩT 1 π
X (e ) = X a ( j Ω), | Ω | <
T T
• can show that the original signal can be recovered from the sampled
signal by interpolation using an ideal LPF of bandwidth π /T, i.e.,
bandlimited sample
∞
⎡ sin(π (t − nT ) / T ) ⎤
xa (t ) = ∑ xa (nT ) ⎢
interpolation—perfect at
• digital-to-analog converter
123
Decimation and Interpolation of
Sampled Waveforms
• CD rate (44.06 kHz) to DAT rate (48 kHz)—media
conversion
• Wideband (16 kHz) to narrowband speech rates (8kHz,
6.67 kHz)—storage
• oversampled to correctly sampled rates--coding
125
Decimation
Standard Sampling: begin with digitized signal:
x[n] = xa (nT ) ↔ X a ( jΩ) = 0, | Ω |≥ 2π FN (a )
1
Fs = ≥ 2 FN
T
1 π
X (e jΩT ) = X a ( jΩ), | Ω |< (b)
T T
X (e ) = 0, 2π FN ≤| Ω |≤ 2π ( Fs − FN )
jΩT
126
Decimation
want to reduce sampling rate of
sampled signal by factor of M ≥ 2
want to compute new signal xd [n]
with sampling rate Fs ' = 1/ T ' = 1( MT ) = Fs / M
such that xd [n] = xa (nT '' ) with no aliasing
one solution is to downsample x[n] = xa (nT )
by retaining one out of every M samples of x[n],
giving xd [n] = x[nM ]
127
Decimation
need
Fs ' ≥ 2 FN
to avoid aliasing for M = 2 (c)
when
Fs ' < 2 FN
we get aliasing for M = 2 (d )
128
Decimation
1
assuming Fs ' = ≥ 2 FN , (i.e., no aliasing) we get:
MT
jΩT ' 1 jΩT '/ M 1 jΩT 1 1
X d (e ) = X (e )= X (e ) = X a ( j Ω)
M M MT
1 π π
= X a ( jΩ), − < Ω < 129
T' T' T'
Decimation
to decimate by factor of M with no aliasing, need to
ensure that the highest frequency in x[n] is no greater
than Fs / (2 M )
thus we need to filter x[n] using an ideal lowpass
filter with response:
jω ⎧1 | ω |< π / M
H d (e ) = ⎨
⎩0 π / M <| ω |≤ π
using the appropriate lowpass filter, we can down-
sample the reuslting lowpass-filtered signal
by a factor of M without aliasing
130
Decimation
using a lowpass filter gives:
1 π π
Wd (e jΩT ' ) = H d (e jΩT ) X a ( jΩ), − < Ω <
T' T' T'
if filter is used, the down-sampled signal, wd [n],
no longer represents the original analog signal,
xa (t ), but instead the lowpass filtered version of
xa (t )
the combined operations of lowpass filtering
and downsampling are called decimation.
131
Interpolation
assume we have x[n] = xa (nT ), (no aliasing) and we wish to increase
the sampling rate by the integer factor of L
we need to compute a new sequence of samples of xa (t ) with period
T '' = T / L, i.e.,
xi [n] = xa (nT '') = xa (nT / L)
It is clear that we can create the signal
xi [n] = x[n / L] for n = 0, ± L, ±2 L,...
but we need to fill in the unknown samples by an interpolation process
can readily show that what we want is:
∞
⎡ sin[π (nT ''− kT ) / T ] ⎤
∑
xi [n] = xa (nT '') = xa ( kT ) ⎢ [π (nT ''− kT ) / T ] ⎥
k =−∞ ⎣ ⎦
equivalently with T '' = T / L, x[n] = xa (nT ) we get
∞
⎡ sin[π (n − k ) / L] ⎤
∑
xi [n] = xa (nT '') = xa ( k ) ⎢ [π (n − k ) / L] ⎥
k =−∞ ⎣ ⎦
which relates xi [n] to x[n] directly 132
Interpolation
implementing the previous equation by filtering the upsampled sequence
⎧ x [n / L] n = 0, ± L, ±2 L,...
xu [n] = ⎨
⎩ 0 otherwise
xu [n] has the correct samples for n = 0, ± L, ±2 L,..., but it has zero-valued
samples in between (from the upsampling operation)
The Fourier transform of xu [n] is simply:
X u (e jω ) = X (e jω L )
X u (e jΩT '' ) = X (e jΩT '' L ) = X (e jΩT )
Thus X u (e jΩT '' ) is periodic with two periods, namely
with period 2π / L, due to upsampling) and 2π due to being a digital signal
133
Interpolation
( a ) Plot of X ( e jΩT )
(b) Plot of X u (e jΩT '' ) showing double
periodicity for L = 2, T '' = T / 2
( c ) DTFT of desired signal with
⎧(2 / T ) X a ( jΩ) | Ω |≤ 2π FN
X i (e jΩT '' ) = ⎨
⎩ 0 2π FN <| Ω |≤ π / T ''
can obtain results of (c ) by applying ideal
lowpass filter with gain L (to restore amplitude)
and cutoff frequency 2π FN = π / T , giving:
jω ⎧(1 / T '') X (e jωL ) 0 ≤| ω |< π / L
X i (e ) = ⎨
⎩ 0 π / L ≤| ω |≤ π
⎧L | ω |< π / L
H i ( e jω ) = ⎨
⎩ 0 π / L ≤| ω |≤ π
134
Interpolation
Original signal, x[n], at sampling period, T ,
is first upsampled to give signal xu [n] with
sampling period T '' = T / L
lowpass filter removes images of original
spectrum giving:
xi [n] = xa (nT '') = xa (nT / L)
135
SR Conversion by Non-Integer Factors
• T’=MT/L => convert rate by factor of M/L
• need to interpolate by L, then decimate by M (why can’t
it be done in the reverse order?)
• can approximate almost any rate conversion with appropriate values of L and M
• for large values of L, or M, or both, can implement in stages, i.e., L=1024, use
L1=32 followed by L2=32
136
Summary of DSP-Part II
• digital filtering provides a convenient way of processing
signals in the time and frequency domains
• can approximate arbitrary spectral characteristics via
either IIR or FIR filters, with various levels of
approximation
• can realize digital filters with a variety of structures,
including direct forms, serial and parallel forms
• once a digital signal has been obtain via appropriate
sampling methods, its sampling rate can be changed
digitally (either up or down) via appropriate filtering and
decimation or interpolation
137