Professional Documents
Culture Documents
Linear Predictive
Coding (LPC)Introduction
s(n ) =
k =1
LPC Methods
LPC Methods
s( n ) s( n N p )
but that is not what LP is doing; it is estimating s(n ) from
the p ( p << N p ) most recent values of s(n ) by linearly
LPC Methods
Basic Principles of LP
p
s( n ) =
k =1
a s( n k ) + G u ( n )
covariance method
autocorrelation method
lattice method
inverse filter formulation
spectral estimation formulation
maximum likelihood method
inner product method
H (z ) =
S( z )
=
GU ( z )
1
p
a z
k
k =1
LP Basic Equations
LP Estimation Issues
e( n ) = s(n ) s%(n ) = s( n )
s(n k )
k =1
A( z ) =
E (z )
= 1 P (z ) = 1
k zk
S( z )
k =1
1
A( z )
en2 (m) =
En
= 0,
i
i = 1, 2,..., p
sn (m)
=
k sn (m k )
m
k =1
of sample n
the key issue to resolve is the range of m for summation
(to be discussed later)
s (m i )[s (m) s (m k )] = 0, 1 i p
n
k n
k =1
s (m i ) e (m) = 0, 1 i p
n
10
defining
n (i , k ) =
En =
s (m i )s (m k )
n
En = n (0, 0)
k =1
we get
k n
2
n
s (m ) s (m ) s ( m k )
i = 1, 2,..., p
(0, k )
k n
k =1
k =1
Process:
1. compute n (i , k ) for 1 i p, 0 k p
2. solve matrix equation for k
need to specify range of m to compute n ( i , k )
11
need to specify sn (m )
12
Autocorrelation Method
Autocorrelation Method
en ( m ) = sn (m )
s (m k )
k n
k =1
En =
e (m ) = e ( m )
2
n
m =
2
n
m =0
at values of m near 0 (i.e., m = 0,1...., p 1) we are predicting signal from zero-valued samples
outside the window range => en ( m ) will be (relatively) large
L samples
for these reasons, normally use windows that taper the segment to zero (e.g., Hamming window)
^n
^
n+L-1
m=0
m=L
m=0
m=L-1
m=L+p-1
m=p-1
13
14
Autocorrelation Method
^n + L 1
sn [m] = s[ m + n ]w[ m]
L-1
L 1 k
s [m]s [m + k ]
Rn [k ] =
m =0
k = 1, 2,K, p
15
16
Autocorrelation Method
for calculation of n (i , k ) since sn (m ) = 0 outside the range 0 m L 1, then
n
sn [m] = s[m + n]w[m]
n + L 1
n + L 1
n (i , k ) =
L 1+ p
s (m i )s (m k ), 1 i p, 0 k p
n
m =0
n (i , k ) =
L 1+( i k )
sn (m )sn ( m + i k ), 1 i p, 0 k p
m =0
Large errors
en [m] = sn [m] k sn [m k]
at ends of s [m] = s[m + n]w[m]
k =1
window
p
L1
1 i p, 0 k p
Rn (k ) =
s (m)s (m + k )
n
m =0
L 1 ( L 1 + p)
17
18
Autocorrelation Method
Autocorrelation Method
n (i , k ) = Rn ( i k ), 1 i p, 0 k p
k n (i k ) = n (i , 0), 1 i p
k =1
p
R ( i k ) = R (i ),
k
1 i p
k =1
with solution
En = n (0, 0)
= 1 r
is a p p Toeplitz Matrix => symmetric with all diagonal elements equal
=> there exist more efficient algorithms to solve for { k } than simple matrix
k n (0, k )
k =1
= Rn (0)
R (k )
k
inversion
k =1
Covariance Method
giving
En =
m =0
n (i , k ) =
=
k sn (m k )
sn (m )
m =0
k =1
L 1
en2 (m )
n (i , k ) =
n (i , k ) =
L i 1
s (m) s (m + i k ), 1 i p, 0 k p
n
m = i
L k 1
s (m) s (m + k i ), 1 i p, 0 k p
n
m = k
L 1
s (m i )s (m k ), 1 i p, 0 k p
n
20
19
Covariance Method
L 1
. . Rn ( p 1) 1 Rn (1)
. . Rn ( p 2) 2 Rn ( 2)
. = .
. .
.
. .
.
. .
. .
Rn (0) p Rn ( p )
Rn (1)
Rn (0)
Rn (0)
Rn (1)
.
.
.
.
R ( p 1) R ( p 2)
n
n
= r
m =0
m=-p
m=L-1
21
Covariance Method
22
Covariance Method
cannot use autocorrelation formulation => this is a true cross correlation
need to solve set of equations of the form
p
i = 1, 2,..., p,
k =1
En = n (0, 0)
n (0, k )
k =1
n (1,1) n (1, 2)
n ( 2,1) n ( 2, 2)
.
.
.
.
( p,1) ( p, 2)
n
n
. . n (1, p ) 1 n (1, 0)
. . n ( 2, p ) 2 n ( 2, 0)
. .
. . = .
. .
. . .
. . n ( p, p ) p n ( p, 0)
= or = 1
23
24
Covariance Method
Summary of LP
use pth order linear predictor to predict s(n ) from p previous samples
minimize mean-squared error, En , over analysis window of duration L-samples
n (i + 1, k + 1) = n (i , k ) + sn ( i 1)sn ( k 1) sn (L 1 i )sn (L 1 k )
n ( 2, 2) = n (1,1) + sn ( 2)sn ( 2) sn (L 2)sn (L 2)
matrix is Toeplitz and can be readily solved using standard matrix solutions
- covariance method => the signal is extended by p samples outside the normal range
need for a tapering window; resulting matrix of correlations is symmetric but not Toeplitz
=> different method of solution with somewhat different set of optimal prediction
coefficients, { k }
25
26
LPC Summary
LPC Summary
3. LPC Minimization:
En = en2 (m ) = sn (m ) s%n (m )
k =1
H(z) =
S( z )
=
GU ( z )
= sn (m ) k sn ( m k )
m
k =1
1
p
1 ak z
En
= 0,
i
k =1
s%(n ) = k s(n k )
i = 1, 2,..., p
p
s (m i )s (m) = s (m i )s (m k )
n
k =1
P(z) =
S% ( z ) p
= k z k
S( z ) k =1
k =1
n (i , k ) = sn (m i )sn (m k )
m
k =1
k =1
p
E(z)
= 1 k z k
A( z ) =
S( z )
k =1
k n
i = 1, 2,..., p
27
LPC Summary
4. Autocorrelation Method:
sn (m ) = s(m + n )w (m ),
En = n (0, 0) kn (0, k )
k =1
28
LPC Summary
4. Autocorrelation Method:
0 m L 1
en (m ) = sn (m ) k sn (m k ), 0 m L 1 + p
k =1
= r or = 1r
L 1+ p
e (m )
m =0
2
n
n (i , k ) = Rn (i k ) =
L 1( i k )
m =0
R ( i k ) = R (i ),
k =1
Rn (1)
Rn (0)
R (1)
R
n
n ( 0)
.
.
.
.
Rn ( p 1) Rn ( p 2)
sn (m )sn (m + i k ) = Rn ( i k
1 i p
. . Rn ( p 1) 1 Rn (1)
. . Rn ( p 2) 2 Rn ( 2)
. = .
. .
.
. .
.
. .
Rn (0) p Rn ( p )
. .
En = Rn (0) k Rn (k )
k =1
29
30
LPC Summary
5. Covariance Method:
the signal energy with the energy of the linearly predicted samples
En = e (m ) = sn (m ) k sn ( m k )
m =0
m =0
k =1
L 1
2
n
(i, k ) =
k =1
Gu( n ) = s( n )
a s(n k ) model
k
k =1
n (i , 0), i = 1, 2,..., p
k n
e(n ) = s(n )
En = n ( 0, 0) kn (0, k )
e(n ) = Gu(n )
= or = 1 , symmetric matrix
. . n (1, p ) 1 n (1, 0)
. . n ( 2, p ) 2 n ( 2, 0)
. = .
. .
. . .
. . n ( p, p ) p n ( p, 0)
. .
k =1
k =1
n (1,1) n (1, 2)
( 2,1) ( 2, 2)
n
n
.
.
.
.
n ( p,1) n ( p, 2)
L 1+ p
L 1+ p
u (m ) = e (m ) = E
G2
m =0
31
m =0
32
Gain Assumptions
h%(n ) =
h%(n k ) + G (n );
k
k =1
G
H% ( z ) =
=
A( z )
G
p
z
k
k =1
radiation
R% (m ) =
0m<
n =0
p
R% ( m k ),
1 m <
R% (k ) + G ,
m=0
R% (m ) =
R% (0) =
k =1
p
k =1
33
for unvoiced speech the input is white noise with zero mean
and unity variance, i.e.,
E u(n ) u (n m ) = (m )
if we excite the system with input Gu(n ) and call the output
g% (n ) then
g% (n ) =
R (k ) = E
g% (n k ) + Gu(n )
k =1
34
k =1
R% (m ) = E g% (n ) g% (n m ) =
p
k R% (m k ),
k =1
m0
k =1
35
36
Frequency
Domain
Interpretations
of Linear
Predictive
Analysis
R% (k ) + GE u(n)g% (n )
k
k =1
p
R% (k ) + G
k
k =1
G = Rn (0)
2
R (k ) = E
n
k =1
37
38
LPC Spectrum
G
p
1 k e jk
G
A(e j )
H% (e j ) =
k =1
39
40
x = s .* hamming(301);
X = fft( x , 1000 )
[ A , G , r ] = autolpc( x , 10 )
H = G ./ fft(A,1000);
( ) s[m + n]w[m] e
j k
Sn e j =
1 k e
k =1
G = En = ( en (m )) = Rn (0) k Rn (k )
2
G
p
j m
m =
42
L + p 1
e [ m]
2
m =0
1
2
| E (e
n
) |2 d =
1
2
G2
2
| Sn (e j ) |2
| H% (e ) | d = G
j
| S (e
n
) |2 | A(e j ) |2 d = G 2
A(e j ) = 1 k e j k
k =1
44
LP Interpretation Example1
Much better
spectral matches
to STFT spectral
peaks than to
STFT spectral
valleys as
predicted by
spectral
interpretation of
error
minimization.
46
LP Interpretation Example2
Note small
differences in
spectral shape
between STFT,
autocorrelation
spectrum and
covariance
spectrum when
using short
window duration
(L=51 samples).
47
48
49
50
51
52
m =0
j (2 / N ) k
Gr
Ar (e j (2 / N ) k )
) are the gain and prediction error polynomial
54
Spectra of synthetic
vowel /IY/
(a) Narrowband
spectrum using
40 msec window
(b) Wideband
spectrum using a
10 msec window
(c) Cepstrally
smoothed
spectrum
(d) LPC spectrum
from a 40 msec
section using a
p=12 order LPC
analysis
55
no discontinuity in model
spectra at 5 kHz
the key idea is to map the frequency region {fA , fB } linearly to {0,.5}
the transformation
2 fA
2 fB
2 fB 2 fA
1
2
| S (e
n
) |2 e j m d
discontinuity in model
spectra at 5 kHz
57
58
i = 1, 2,..., p
k =1
59
60
10
n (i , j ) =
ik d kV jk ,
1 j i 1
11
21
31
41
k =1
giving
Vij d j = n (i , j )
j 1
1 j i 1
ik d kV jk ,
k =1
n (i , i ) =
ik d kVik
0
0
1
0
V21 1
V31 V32 1
k =1
giving
d i = n (i , i )
i 1
V
k =1
2
ik
i2
dk ,
with
d1 = n (1,1)
0 d1 0
0 0 d2
0 0 0
1 0 0
31
32
33
34
0
0
d3
0
41
42
=
43
44
0 1 V21 V31 V41
0 0 1 V32 V42
0 0 0
1 V43
d 4 0 0
0
1
61
step 1
writing this as
VY= with
step 2
DV t = Y or
V t = D1Y
step 3
Yi = i
pi 2
64
co n tin u in g th e e xa m p le w e so lv e fo r Y
0 Y1 1
0 Y 2 2
=
0 Y 3 3
V 42 V 43 1 Y 4 4
first so lv in g fo r Y1 Y 4 w e g e t
1
V 21
V 31
V 41
ij
i 1
V Y ,
j =1
63
V ,
62
i = Yi / d i
21
22
32
42
1 i p 1
j = i +1
0
1
V 32
0
0
1
Y1 = 1
Y 2 = 2 V 21Y1
Y 3 = 3 V 31Y1 V 32Y 2
Y 4 = 4 V 41Y1 V 42Y 2 V 43Y 3
66
11
0
0 Y2 Y2 / d 2
0 1 V32 V42 2 = 0 1 / d 2
=
0 0
0
1 / d3
0 Y3 Y3 / d3
1 V43 3 0
0
0
1 / d 4 Y4 Y4 / d 4
0
1 4 0
0 0
giving the results
4 = Y4 / d 4
3 = Y3 / d3 V43 4
2 = Y2 / d 2 V32 3 V42 4
1 = Y1 / d1 V21 2 V31 3 V41 4
En = n (0, 0)
(0, k )
k n
k =1
t
= n (0, 0)
= n ( 0, 0)
2
k
/ dk
k =1
this computation for En can be used for all values of LP order from
1 to p can understand how LP order reduces mean-squared error
68
69
Levinson-Durbin Algorithm 1
70
Levinson-Durbin Algorithm 2
R[| i k |] = R[i ] 1 i p
r
=
k =1
R[ p ] 1 E ( p )
( p)
... R[ p 1] 1 0
( p)
... R[ p 2] 2 = 0
.
.
. .
( p)
...
R[0] p 0
expanded (p + 1) x ( p + 1) matrix is still Toeplitz and can be solved iteratively
by incorporating new correlation value at each iteration and
R[1]
R[2]
R[0]
R[1]
R[0]
R[1]
R[2]
R[1]
R[0]
.
.
.
R[ p ] R[ p 1] R[ p 2]
R[i] k R[| i k |] = 0,
1 i p
k =1
...
R[0] k R[k ] = E ( p )
k =1
71
72
12
Levinson-Durbin Algorithm 3
Levinson-Durbin Algorithm 4
R[1]
R[2]
R[0]
R[1]
R[0]
R[1]
R[2]
R[1]
R[0]
.
.
.
R[i 1] R[i 2] R[i 3]
R[i 1] R[i 2]
R[i]
R[2]
R[1]
R[0]
.
.
.
R[i 1] R[i 2] R[i 3]
... R[i 1] 1 E ( i 1)
... R[i 2] 1( i 1) 0
( i 1)
= 0
... R[i 3] 2
.
. . .
( i 1)
R[0] i 1 0
...
...
R[i] 1 E (i 1)
... R[i 1] 1( i 1) 0
... R[i 2] 2( i 1) 0
=
...
. . .
( i 1)
R[1]
i 1
...
0
R[0] 0 ( i 1)
...
i 1
73
74
Levinson-Durbin Algorithm 5
Levinson-Durbin Algorithm 6
R[2]
R[1]
R[0]
.
.
.
R[i 1] R[i 2] R[i 3]
R[i 1] R[i 2]
R[i ]
...
...
...
...
...
...
1
( i 1)
0 E ( i 1)
( i 1)
( i 1)
1
0
i 1 0
( i 1)
i(i 21) 0
( i ) 2
R
ki
ki
=
.
.
. .
i(i11)
0
1( i 1) 0
( i 1)
( i 1)
E
0
1
R[i ] 0
R[i 1] i(i11) 0
R[i 2] i(i 21) 0
=
. . .
(
i
1)
R[1] 1 0
R[0] 1 E (i 1)
( i 1)
ki =
75
Levinson-Durbin Algorithm 7
The first element of the right hand side vector is now:
j =1
E ( i 1)
76
1 j p
m =1
m =1
1 1
0
(i ) (i 1)
( i 1)
1 1
i 1
(i )
( i 1)
2 2
i(i 21)
=
ki
. .
.
i(i1) i(i11)
1( i 1)
(i )
1
i 0
(i ) =
Levinson-Durbin Algorithm 7
j = (j p )
E ( i 1)
E (i ) = E (i 1) ki (i 1) = E (i 1) (1 ki2 )
( i 1)
( i 1)
77
i
i
E (i )
= 1 k(i ) r[k ] = (1 km2 )
R[0]
k =1
m =1
78
13
Levinson-Durbin Algorithm
Autocorrelation Example
consider a simple p = 2 solution of the form
R(0) R(1) 1 R(1)
R(1) R(0) 2 R( 2)
with solution
A( i ) (z) = A( i 1) (z)
ki zi A( i 1) (z1 )
E ( 0 ) = R (0)
k1 = R(1) / R(0)
79
Vn =
R( 2)R(0) R (1)
2( 2 ) =
1( 2 ) =
80
Autocorrelation Example
k2 =
R 2 (0) R 2 (1)
R ( 0)
R 2 (0) R 2 (1)
p
En
R [k ]
= 1 k n
Rn [0]
Rn [0]
k =1
R( 2)R(0) R 2 (1)
R 2 (0) R 2 (1)
R(1)R(0) R (1)R ( 2)
R 2 (0) R 2 (1)
with final coefficients
1 = 1( 2 )
2 = 2( 2 )
E ( i ) = prediction error for predictor of order i
81
82
minimum-phase property
zeros of A(z) are inside the unit circle
Levinson-Durbin recursion
efficient algorithm for finding prediction coefficients
PARCOR coefficients and MSE are by-products
83
14