aec filter design toolbox
TRANSCRIPT
-
8/19/2019 Aec Filter Design Toolbox
1/11
Filter Design Toolbox
Acoust ic Echo Cancellation (AEC)
This demonstration illustrates the application of adaptive filters to acoustic echo cancellation (AEC).
Author(s): Scott C. Douglas
Contents
Introduction
The Room Impulse Response
The Near-End Speech Signal
The Far-End Speech Signal
The Microphone Signal
The Frequency-Domain Adaptive Filter (FDAF)
Echo Return Loss Enhancement (ERLE)
Effects of Different Step Size Values
Echo Return Loss Enhancement Comparison
Introduction
Acoustic echo cancellation is important for audio teleconferencing when simultaneous communication (or full-duplex
transmission) of speech is necessary. In acoustic echo cancellation, a measured microphone signal d(n) contains two signals:
- the near-end speech signal v(n) - the far-end echoed speech signal dhat(n) The goal is to remove the far-end echoed
speech signal from the microphone signal so that only the near-end speech signal is transmitted. This demo has some sound
clips, so you might want to adjust your computer's volume now.
The Room Impulse Response
First, we describe the acoustics of the loudspeaker-to-microphone signal path where the speakerphone is located. We can
use a long finite impulse response filter to describe these characteristics. The following sequence of commands generates a
random impulse response that is not unlike what a conference room would exhibit assuming a system sampling rate of fs =
8000 Hz.
M = 4001;
f s = 8000;
[ B, A] = cheby2( 4, 20, [ 0. 1 0. 7] ) ;
Hd = df i l t . df 2t ( [ zeros( 1, 6) B] , A) ;
-
8/19/2019 Aec Filter Design Toolbox
2/11
hFVT = f vtool ( Hd) ; % Anal yze t he f i l t er
set ( hFVT, ' Col or ' , [ 1 1 1] )
H = f i l t er ( Hd, l og( 0. 99*r and( 1, M) +0. 01) . * . . .
si gn( r andn( 1, M) ) . *exp( - 0. 002*( 1: M) ) ) ;
H = H/ norm( H) *4; % RoomI mpul se Response
pl ot ( 0: 1/ f s :0. 5, H) ;
xl abel ( ' Ti me [ sec] ' ) ;
yl abel ( ' Ampl i t ude' ) ;
t i t l e( ' Room I mpul se Response' ) ;
set ( gcf , ' Col or ' , [ 1 1 1] )
The Near-End Speech Signal
-
8/19/2019 Aec Filter Design Toolbox
3/11
The teleconferencing system's user is typically located near the system's microphone. Here is what a male speech sounds
like at the microphone.
l oad near speech
n = 1: l engt h( v) ;
t = n/ f s;
pl ot ( t , v) ;
axi s([ 0 33. 5 - 1 1] ) ;
xl abel ( ' Ti me [ sec] ' ) ;
yl abel ( ' Ampl i t ude' ) ;
t i t l e( ' Near - End Speech Si gnal ' ) ;
set ( gcf , ' Col or ' , [ 1 1 1] )
p8 = audi opl ayer ( v, f s) ;
pl aybl ocki ng( p8) ;
The Far-End Speech Signal
Now we describe the path of the far-end speech signal. A male voice travels out the loudspeaker, bounces around in the
room, and then is picked up by the system's microphone. Let's listen to what his speech sounds like if it is picked up at the
microphone without the near-end speech present.
l oad f arspeech
x = x( 1: l engt h( x) ) ;
-
8/19/2019 Aec Filter Design Toolbox
4/11
dhat = f i l t er( H, 1, x) ;
pl ot ( t , dhat ) ;
axi s([ 0 33. 5 - 1 1] ) ;
xl abel ( ' Ti me [ sec] ' ) ;
yl abel ( ' Ampl i t ude' ) ;
t i t l e( ' Far- End Echoed Speech Si gnal ' ) ;
set ( gcf , ' Col or ' , [ 1 1 1] )
p8 = audi opl ayer ( dhat , f s) ;
pl aybl ocki ng( p8) ;
The Microphone Signal
The signal at the microphone contains both the near-end speech and the far-end speech that has been echoed throughout
the room. The goal of the acoustic echo canceler is to cancel out the far-end speech, such that only the near-end speech is
transmitted back to the far-end listener.
d = dhat + v+0. 001*r andn( l ength( v) , 1) ;
pl ot ( t , d) ;
axi s([ 0 33. 5 - 1 1] ) ;
xl abel ( ' Ti me [ sec] ' ) ;
yl abel ( ' Ampl i t ude' ) ;
t i t l e( ' Mi cr ophone Si gnal ' ) ;
-
8/19/2019 Aec Filter Design Toolbox
5/11
set ( gcf , ' Col or ' , [ 1 1 1] )
p8 = audi opl ayer ( d, f s) ;
pl aybl ocki ng( p8) ;
The Frequency-Domain Adaptive Filter (FDAF)
The algorithm that we will use in this demonstration is the Frequency-Domain Adaptive Filter (FDAF). This algorithm is very
useful when the impulse response of the system to be identified is long. The FDAF uses a fast convolution technique to
compute the output signal and filter updates. This computation executes quickly in MATLAB®. It also has improved
convergence performance through frequency-bin step size normalization. We'll pick some initial parameters for the filter and
see how well the far-end speech is cancelled in the error signal.
mu = 0. 025;
W0 = zer os( 1, 2048) ;
del = 0. 01;
l am = 0. 98;
x = x( 1: l engt h( W0) *f l oor ( l engt h( x)/ l engt h( W0) ) ) ;
d = d( 1: l engt h( W0) *f l oor ( l engt h( d) / l engt h( W0) ) ) ;
% Const r uct t he Frequency- Domai n Adapt i ve Fi l t er
hFDAF = adapt f i l t . f daf ( 2048, mu, 1, del , l am) ;
[ y, e] = f i l t er ( hFDAF, x, d) ;
-
8/19/2019 Aec Filter Design Toolbox
6/11
n = 1: l engt h( e) ;
t = n/ f s;
pos = get ( gcf , ' Pos i t i on' ) ;
set ( gcf , ' Pos i t i on' , [ pos( 1) , pos( 2) - 100, pos( 3) , ( pos( 4) +85) ] )
subpl ot ( 3, 1, 1) ;
pl ot ( t , v(n) , ' g' ) ;
axi s([ 0 33. 5 - 1 1] ) ;
yl abel ( ' Ampl i t ude' ) ;
t i t l e( ' Near - End Speech Si gnal ' ) ;
subpl ot ( 3, 1, 2) ;
pl ot ( t , d(n) , ' b' ) ;
axi s([ 0 33. 5 - 1 1] ) ;
yl abel ( ' Ampl i t ude' ) ;
t i t l e( ' Mi cr ophone Si gnal ' ) ;
subpl ot ( 3, 1, 3) ;
pl ot ( t , e(n) , ' r ' ) ;
axi s([ 0 33. 5 - 1 1] ) ;
xl abel ( ' Ti me [ sec] ' ) ;
yl abel ( ' Ampl i t ude' ) ;
t i t l e( ' Out put of Acoust i c Echo Cancel l er ' ) ;
set ( gcf , ' Col or ' , [ 1 1 1] )
p8 = audi opl ayer ( e/ max(abs( e) ) , f s) ;
pl aybl ocki ng( p8) ;
-
8/19/2019 Aec Filter Design Toolbox
7/11
Echo Return Loss Enhancement (ERLE)
Since we have access to both the near-end and far-end speech signals, we can compute the echo return loss enhancement
(ERLE), which is a smoothed measure of the amount (in dB) that the echo has been attenuated. From the plot, we see that
we have achieved about a 30 dB ERLE at the end of the convergence period.
Hd2 = df i l t . df f i r ( ones( 1, 1000) ) ;
set f i l t er( hFVT, Hd2) ;
er l e = f i l t er( Hd2, ( e- v( 1: l engt h( e) ) ) . 2̂) . / . . .
( f i l t er ( Hd2, dhat ( 1: l engt h( e) ) . 2̂) ) ;
er l edB = - 10*l og10( er l e) ;
-
8/19/2019 Aec Filter Design Toolbox
8/11
pl ot ( t , er l edB) ;
axi s( [ 0 33. 5 0 40] ) ;
xl abel ( ' Ti me [ sec] ' ) ;
yl abel ( ' ERLE [ dB] ' ) ;
t i t l e( ' Echo Ret urn Loss Enhancement ' ) ;
set ( gcf , ' Col or ' , [ 1 1 1] )
Effects o f Different Step Size Values
To get faster convergence, we can try using a larger step size value. However, this increase causes another effect, that is,
the adaptive filter is "mis-adjusted" while the near-end speaker is talking. Listen to what happens when we choose a step
size that is 60\% larger than before
newmu = 0. 04;
set ( hFDAF, ' St epSi ze' , newmu) ;
[ y, e2] = f i l t er ( hFDAF, x, d) ;
pos = get ( gcf , ' Pos i t i on' ) ;
set ( gcf , ' Pos i t i on' , [ pos( 1) , pos( 2) - 100, pos( 3) , ( pos( 4) +85) ] )
subpl ot ( 3, 1, 1) ;
pl ot ( t , v(n) , ' g' ) ;
-
8/19/2019 Aec Filter Design Toolbox
9/11
axi s([ 0 33. 5 - 1 1] ) ;
yl abel ( ' Ampl i t ude' ) ;
t i t l e( ' Near - End Speech Si gnal ' ) ;
subpl ot ( 3, 1, 2) ;
pl ot ( t , e(n) , ' r ' ) ;
axi s([ 0 33. 5 - 1 1] ) ;
yl abel ( ' Ampl i t ude' ) ;
t i t l e( ' Out put of Acoust i c Echo Cancel l er , \ mu = 0. 025' ) ;
subpl ot ( 3, 1, 3) ;
pl ot ( t , e2( n) , ' r ' ) ;
axi s([ 0 33. 5 - 1 1] ) ;
xl abel ( ' Ti me [ sec] ' ) ;
yl abel ( ' Ampl i t ude' ) ;
t i t l e( ' Out put of Acoust i c Echo Cancel l er , \ mu = 0. 04' ) ;
set ( gcf , ' Col or ' , [ 1 1 1] )
p8 = audi opl ayer ( e2/ max( abs( e2) ) , f s) ;
pl aybl ocki ng( p8) ;
-
8/19/2019 Aec Filter Design Toolbox
10/11
Echo Return Loss Enhancement Comparison
With a larger step size, the ERLE performance is not as good due to the misadjustment introduced by the near-end speech.To deal with this performance difficulty, acoustic echo cancellers include a detection scheme to tell when near-end speech is
present and lower the step size value over these periods. Without such detection schemes, the performance of the system
with the larger step size is not as good as the former, as can be seen from the ERLE plots.
cl ose;
er l e2 = f i l t er ( Hd2, ( e2- v( 1: l engt h( e2) ) ) . 2̂) . / . . .
( f i l t er ( Hd2, dhat ( 1: l engt h( e2) ) . 2̂) ) ;
er l e2dB = - 10*l og10( er l e2) ;
pl ot ( t , [ er l edB er l e2dB] ) ;
axi s( [ 0 33. 5 0 40] ) ;
xl abel ( ' Ti me [ sec] ' ) ;
yl abel ( ' ERLE [ dB] ' ) ;
-
8/19/2019 Aec Filter Design Toolbox
11/11
t i t l e( ' Echo Ret urn Loss Enhancement s' ) ;
l egend( ' FDAF, \ mu = 0. 025' , ' FDAF, \ mu = 0. 04' ) ;
set ( gcf , ' Col or ' , [ 1 1 1] )