| Purpose |
| Simulation of an acoustic echo canceler application using a transversal adaptive filter updated according to the Normalized Least Mean Squares (NLMS) algorithm. |
| Syntax |
echo_nlms
|
| Description |
The block diagram of the acoustic echo cancellation problem is shown in
Fig. 10.31. The simulation considered here uses a transversal FIR
filter for the adjustable filter and the coefficients of the filter are updated
in time domain using the NLMS algorithm. The far-end speech signal
init_nlms(),
and the input signals are read from files, then a processing loop is started.
In each iteration of the loop asptnlms() is called with a new
sample from the FES and a new sample from the NES signals to calculate
the filter output
|
| Code |
clear all; infile = '.\wavin\aecfes.wav'; % Far-end speech (FES) dfile = '.\wavin\aecnes.wav'; % Near-end speech (NES) rfile = '.\wavout\resnlms.wav'; % residual signal M = 512; % adaptive filter length mu = 0.2/M; % adaptation constant b = 0.99; % autoregressive pole [w,x,d,y,e,p] = init_nlms(M); % Init NLMS [xn,inFs,inBits] = wavread(infile); % read FES [dn,inFs,dBits] = wavread(dfile); % read NES inSize = max(length(xn),length(dn)); % Samples to process res = dn; % Residual array E = init_ipwin(inSize); % Initialize IPWIN %% Processing Loop for (m=1:inSize) % update the delay line x = [2^(inBits-1) * xn(m); x(1:M-1)]; % scale the Mic signal d = 2^(inBits-1) *dn(m); % call asptnlms to update the filter [w,y,e,p]= asptnlms(x,w,d,mu,p,b); % save the last residual sample res(m) = 2^-(inBits-1)*e; % update the iteration progress window [E, stop,brk] = update_ipwin(E,e,d, 'e', w, dn, res); % handle the Stop button while (stop ~= 0), stop = getStop; end; % handle the Break button if (brk), plot_echo(w,dn,res); break; end; end; wavwrite(res,inFs,inBits,rfile); % Save the residual plot_echo(w, dfile, rfile); % Show results |
| Results |
Running the above script will produce the graph shown in Fig. 10.32.
The top panel in Fig. 10.32 shows the values taken by the filter
coefficients by the end of the simulation (end of input files). The middle panel
show the waveforms of the near-end speech signal
|
| Audio Files |
The following files demonstrate the performance of the NLMS algorithm in the echo canceler application mentioned above.
|
| See Also |
| INIT_ NLMS, ASPTNLMS. |
| Reference |
| [11] and [4] for extensive analysis of the NLMS and the steepest-descent search method. |