![Simple program in matlab Simple program in matlab](/uploads/1/2/5/8/125867942/689982530.png)
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 contains two signals. I need a matlab code for echo cancellation using adaptive algorithms.
![Cancellation Cancellation](/uploads/1/2/5/8/125867942/828309578.jpg)
- Published on
24-Nov-2015 - View
460 - Download
6
Embed Size (px)
Transcript
- 27/2/2014 Acoustic Echo Cancellation (AEC) - MATLAB & Simulink Example - MathWorks Francehttp://www.mathworks.fr/fr/help/dsp/examples/acoustic-echo-cancellation-aec.html 1/7Acoustic Echo Cancellation (AEC)This example show s how to apply adaptive f ilters to acoustic echo cancellation (AEC).Author(s): Scott C. DouglasIntroductionAcoustic echo cancellation is important for audio teleconferencing w hen simultaneous communication (or full-duplextransmission) of speech is necessary. In acoustic echo cancellation, a measured microphone signal d(n) contains tw o signals:- the near-end speech signal v(n) - the far-end echoed speech signal dhat(n) The goal is to remove the far-end echoedspeech signal from the microphone signal so that only the near-end speech signal is transmitted. This example has some soundclips, so you might w ant to adjust your computer's volume now .The Room Impulse ResponseFirst, w e describe the acoustics of the loudspeaker-to-microphone signal path w here the speakerphone is located. We canuse a long f inite impulse response f ilter to describe these characteristics. The follow ing sequence of commands generates arandom impulse response that is not unlike w hat a conference room w ould exhibit assuming a system sampling rate of fs =8000 Hz.M = 4001;fs = 8000;[B,A] = cheby2(4,20,[0.1 0.7]);Hd = dfilt.df2t([zeros(1,6) B],A);hFVT = fvtool(Hd); % Analyze the filterset(hFVT, 'Color', [1 1 1])H = filter(Hd,log(0.99*rand(1,M)+0.01).* ...sign(randn(1,M)).*exp(-0.002*(1:M)));H = H/norm(H)*4; % Room Impulse Responseplot(0:1/fs:0.5,H);xlabel('Time [sec]');ylabel('Amplitude');title('Room Impulse Response');set(gcf, 'Color', [1 1 1])
- 27/2/2014 Acoustic Echo Cancellation (AEC) - MATLAB & Simulink Example - MathWorks Francehttp://www.mathworks.fr/fr/help/dsp/examples/acoustic-echo-cancellation-aec.html 2/7The Near-End Speech SignalThe teleconferencing system's user is typically located near the system's microphone. Here is w hat a male speech sounds likeat the microphone.load nearspeechn = 1:length(v);t = n/fs;plot(t,v);axis([0 33.5 -1 1]);xlabel('Time [sec]');ylabel('Amplitude');title('Near-End Speech Signal');set(gcf, 'Color', [1 1 1])p8 = audioplayer(v,fs);playblocking(p8);The Far-End Speech Signal
- 27/2/2014 Acoustic Echo Cancellation (AEC) - MATLAB & Simulink Example - MathWorks Francehttp://www.mathworks.fr/fr/help/dsp/examples/acoustic-echo-cancellation-aec.html 3/7Now w e describe the path of the far-end speech signal. A male voice travels out the loudspeaker, bounces around in theroom, and then is picked up by the system's microphone. Let's listen to w hat his speech sounds like if it is picked up at themicrophone w ithout the near-end speech present.load farspeechx = x(1:length(x));dhat = filter(H,1,x);plot(t,dhat);axis([0 33.5 -1 1]);xlabel('Time [sec]');ylabel('Amplitude');title('Far-End Echoed Speech Signal');set(gcf, 'Color', [1 1 1])p8 = audioplayer(dhat,fs);playblocking(p8);The Microphone SignalThe signal at the microphone contains both the near-end speech and the far-end speech that has been echoed throughout theroom. The goal of the acoustic echo canceler is to cancel out the far-end speech, such that only the near-end speech istransmitted back to the far-end listener.d = dhat + v+0.001*randn(length(v),1);plot(t,d);axis([0 33.5 -1 1]);xlabel('Time [sec]');ylabel('Amplitude');title('Microphone Signal');set(gcf, 'Color', [1 1 1])p8 = audioplayer(d,fs);playblocking(p8);
- 27/2/2014 Acoustic Echo Cancellation (AEC) - MATLAB & Simulink Example - MathWorks Francehttp://www.mathworks.fr/fr/help/dsp/examples/acoustic-echo-cancellation-aec.html 4/7The Frequency-Domain Adaptive Filter (FDAF)The algorithm that w e w ill use in this example is the Frequency-Domain Adaptive Filter (FDAF). This algorithm is very usefulw hen the impulse response of the system to be identif ied is long. The FDAF uses a fast convolution technique to compute theoutput signal and f ilter updates. This computation executes quickly in MATLAB. It also has improved convergence performancethrough frequency-bin step size normalization. We'll pick some initial parameters for the f ilter and see how w ell the far-endspeech is cancelled in the error signal.mu = 0.025;W0 = zeros(1,2048);del = 0.01;lam = 0.98;x = x(1:length(W0)*floor(length(x)/length(W0)));d = d(1:length(W0)*floor(length(d)/length(W0)));% Construct the Frequency-Domain Adaptive FilterhFDAF = adaptfilt.fdaf(2048,mu,1,del,lam);[y,e] = filter(hFDAF,x,d);n = 1:length(e);t = n/fs;pos = get(gcf,'Position');set(gcf,'Position',[pos(1), pos(2)-100,pos(3),(pos(4)+85)])subplot(3,1,1);plot(t,v(n),'g');axis([0 33.5 -1 1]);ylabel('Amplitude');title('Near-End Speech Signal');subplot(3,1,2);plot(t,d(n),'b');axis([0 33.5 -1 1]);ylabel('Amplitude');title('Microphone Signal');subplot(3,1,3);plot(t,e(n),'r');axis([0 33.5 -1 1]);xlabel('Time [sec]');ylabel('Amplitude');title('Output of Acoustic Echo Canceller');set(gcf, 'Color', [1 1 1])p8 = audioplayer(e/max(abs(e)),fs);playblocking(p8);
- 27/2/2014 Acoustic Echo Cancellation (AEC) - MATLAB & Simulink Example - MathWorks Francehttp://www.mathworks.fr/fr/help/dsp/examples/acoustic-echo-cancellation-aec.html 5/7Echo Return Loss Enhancement (ERLE)Since w e have access to both the near-end and far-end speech signals, w e can compute the echo return loss enhancement(ERLE), w hich is a smoothed measure of the amount (in dB) that the echo has been attenuated. From the plot, w e see that w ehave achieved about a 30 dB ERLE at the end of the convergence period.Hd2 = dfilt.dffir(ones(1,1000));setfilter(hFVT,Hd2);erle = filter(Hd2,(e-v(1:length(e))).^ 2)./ ...(filter(Hd2,dhat(1:length(e)).^ 2));erledB = -10*log10(erle);plot(t,erledB);axis([0 33.5 0 40]);xlabel('Time [sec]');ylabel('ERLE [dB]');title('Echo Return Loss Enhancement');set(gcf, 'Color', [1 1 1])
- 27/2/2014 Acoustic Echo Cancellation (AEC) - MATLAB & Simulink Example - MathWorks Francehttp://www.mathworks.fr/fr/help/dsp/examples/acoustic-echo-cancellation-aec.html 6/7Effects of Different Step Size ValuesTo get faster convergence, w e can try using a larger step size value. How ever, this increase causes another effect, that is,the adaptive f ilter is 'mis-adjusted' w hile the near-end speaker is talking. Listen to w hat happens w hen w e choose a step sizethat is 60% larger than beforenewmu = 0.04;set(hFDAF,'StepSize',newmu);[y,e2] = filter(hFDAF,x,d);pos = get(gcf,'Position');set(gcf,'Position',[pos(1), pos(2)-100,pos(3),(pos(4)+85)])subplot(3,1,1);plot(t,v(n),'g');axis([0 33.5 -1 1]);ylabel('Amplitude');title('Near-End Speech Signal');subplot(3,1,2);plot(t,e(n),'r');axis([0 33.5 -1 1]);ylabel('Amplitude');title('Output of Acoustic Echo Canceller, mu = 0.025');subplot(3,1,3);plot(t,e2(n),'r');axis([0 33.5 -1 1]);xlabel('Time [sec]');ylabel('Amplitude');title('Output of Acoustic Echo Canceller, mu = 0.04');set(gcf, 'Color', [1 1 1])p8 = audioplayer(e2/max(abs(e2)),fs);playblocking(p8);
- 27/2/2014 Acoustic Echo Cancellation (AEC) - MATLAB & Simulink Example - MathWorks Francehttp://www.mathworks.fr/fr/help/dsp/examples/acoustic-echo-cancellation-aec.html 7/7Echo Return Loss Enhancement ComparisonWith a larger step size, the ERLE performance is not as good due to the misadjustment introduced by the near-end speech. Todeal w ith this performance diff iculty, acoustic echo cancellers include a detection scheme to tell w hen near-end speech ispresent and low er the step size value over these periods. Without such detection schemes, the performance of the systemw ith the larger step size is not as good as the former, as can be seen from the ERLE plots.close;erle2 = filter(Hd2,(e2-v(1:length(e2))).^ 2)./...(filter(Hd2,dhat(1:length(e2)).^ 2));erle2dB = -10*log10(erle2);plot(t,[erledB erle2dB]);axis([0 33.5 0 40]);xlabel('Time [sec]');ylabel('ERLE [dB]');title('Echo Return Loss Enhancements');legend('FDAF, mu = 0.025','FDAF, mu = 0.04');set(gcf, 'Color', [1 1 1])