An adaptive filter is a computational device that iteratively models the connection between the input and output signals of the filter. An adaptive filter self-adjusts the filter coefficients consistent with an adaptive algorithmic program. The subsequent figure shows the diagram of a typical adaptive filter…

Consider a scenario where two individuals, John and Emily, are talking over the Internet. John is using his loudspeakers, which means Emily can hear herself through John’s microphone. The speech signal that Emily hears, is a distorted version of her own. This is caused by the acoustic path from John’s loudspeakers to his microphone. This path includes attenuated echoes, etc.

Now for the problem!

Emily wishes to cancel the echo she hears from John’s microphone. Emily only knows the speech signal she sends to him, call that u(n), and the speech signal she receives from him, call that d(n). To successfully remove her own echo from d(n), she must approximate the acoustic path from John’s loudspeakers to his microphone. This path can be approximated by a FIR filter, which means an adaptive NLMS FIR filter can be used to identify it. The model which Emily uses to design this filter looks like this:

As seen, the signal that is sent to John is also used as input to the adaptive NLMS filter. The output of the filter, y(n), is subtracted from the signal received from John, which results in an error signal e(n) = d(n)-y(n). By feeding the error signal back to the adaptive filter, it can minimize the error by approximating the impulse response (that is the FIR filter coefficients) of John’s room. Note that so far John’s speech signal v(n) has not been taken into account. If John speaks, the error should equal his speech, that is, e(n) should equal v(n). For this simple example, however, we assume John is quiet and v(n) is equal to white Gaussian background noise with zero-mean. In the following example we keep the impulse response of John’s room constant.

This is not required, however, since the advantage of adaptive filters, is that they can be used to track changes in the impulse response.

Python

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

importnumpy asnp

importmatplotlib.pyplot asplt

importadaptfilt asadf

# Get u(n) - this is available on github or pypi in the examples folder