### Introduction

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 main goal is to remove the far-end echoed speech signal from the microphone signal so that only the near-end speech signal gets transmitted.

### The Room Impulse Response

First, we tend to describe the acoustics of the loudspeaker-to-microphone signal path wherever the speakerphone is located. We can use a protracted finite impulse response filter to explain these characteristics. The subsequent sequence of commands generates a random impulse response that’s not unlike what a conference room would exhibit assuming a system sampling rate of fs = 16000 Hertz.

``` fs = 16000; M = fs/2 + 1; frameSize = 8192; [B,A] = cheby2(4,20,[0.1 0.7]); IIR = dsp.IIRFilter('Numerator', [zeros(1,6) B], 'Denominator', A); FVT = fvtool(IIR); % Analyze the filter FVT.Color = [1 1 1]; 123456789 fs = 16000;M = fs/2 + 1;frameSize = 8192; [B,A] = cheby2(4,20,[0.1 0.7]);IIR = dsp.IIRFilter('Numerator', [zeros(1,6) B], 'Denominator', A); FVT = fvtool(IIR);  % Analyze the filterFVT.Color = [1 1 1]; ``` ``` H = step(IIR, ... (log(0.99*rand(1,M)+0.01).*sign(randn(1,M)).*exp(-0.002*(1:M)))'); H = H/norm(H)*4; % Room Impulse Response firRoom = dsp.FIRFilter('Numerator', H'); fig = figure; plot(0:1/fs:0.5, H); xlabel('Time [sec]'); ylabel('Amplitude'); title('Room Impulse Response'); fig.Color = [1 1 1]; 1234567891011 H = step(IIR, ...    (log(0.99*rand(1,M)+0.01).*sign(randn(1,M)).*exp(-0.002*(1:M)))');H = H/norm(H)*4;    % Room Impulse ResponsefirRoom = dsp.FIRFilter('Numerator', H'); fig = figure;plot(0:1/fs:0.5, H);xlabel('Time [sec]');ylabel('Amplitude');title('Room Impulse Response');fig.Color = [1 1 1]; ``` 