### Thoughts On Adaptive Filtering Algorithms

Adaptive filtering algorithms have been used in wide areas including communication, signal processing,
control systems, biomedical, etc. A basic thought about adaptive filtering and its principles is needed for
the proper understanding of allied techniques. In the field of ANC, I have encountered manly Least
Mean Square (LMS) and Filtered-x LMS.

Some thoughts around which these ideas can be framed as follows. Why should one go for adaptive
filtering? why don't normal filtering alone would fine?. How adaptive the so-called adaptive algorithm
would be? Is there a measure or metric for the adaptiveness property? What is the difference between
LMS and Recursive Least Squares (RLS) algorithm will be?. What are the assumptions around which
adaptive algorithms are framed upon?. Are they guaranteed to converge in all cases?

RLS Detour

The Wikipedia page of RLS says a few important points about its characteristics. The cost function is
the least squares. Does that mean it is not taking the mean value like in LMS?. One assumption for
RLS is that the input signal is considered to be deterministic. If that is the case then why would we
need to predict the signal at all? or Am I missing something big here?. In LMS the input signals are
considered to be stochastic. RLS offers fast convergence compared to its competitors at the cost of
computational complexity. One surprising thing I learned was that the inventor RLS is Gauss!.
Why and at what part computational complexity comes is to be explored.

## Screen Display Specifications

```%Measure screen size of the device
%Calculate position values of figure Windows

scrsz = get(0,'ScreenSize');
P1=[40 500 scrsz(3)/3 scrsz(4)/3];
P2=[40 80 scrsz(3)/3 scrsz(4)/3];
P3=[600 500 scrsz(3)/3 scrsz(4)/3];
P4=[600 80 scrsz(3)/3 scrsz(4)/3];
P5=[1000 500 scrsz(3)/3 scrsz(4)/3];
P6=[1000 80 scrsz(3)/3 scrsz(4)/3];
```

```[y, Fs] = audioread('C:\Users\SAJIL\Documents\MATLAB\DTMF1.wav');
L=length(y);
N = nextpow2(L);
T=1/Fs;
```

## Signal Analysis Part

```t=(0:T:(L-1)/Fs)';
NFFT = 2^nextpow2(L);
Y = fft(y,NFFT);%/L;
f = Fs/2*linspace(0,1,NFFT/2+1);
Mag=2*abs(Y(1:NFFT/2+1));
```

## Plot Signal

```figure('position', P1);
figure(1);
plot(t,y,'k');
grid on
title('Time Domain');
xlabel('Time in Seconds');
ylabel('Amplitude');
legend('DTMF Tone');
``` ## Plot single-sided Amplitude Spectrum.

```figure('position',P2);
figure(2);
plot(f,Mag);
grid on
title('Magnitude Spectrum');
xlabel('Frequency (Hz)');
ylabel('|X(f)|');
legend('Frequency Spectrum');
``` ## DTMF Signal Table

```I = imread('DTMF.png');
figure('position',P3);
figure(3);
image(I)
f=text(0.4,0.4,'Original Input is 0696675356','FontSize',12);
axis off
``` ## Spectrogram Display Part

```figure('position',P4);
figure(4);
%spectrogram(x,window,noverlap,f,fs)
spectrogram(y,32);
text(0.4,28,'Frame Size 32','FontSize',12);
%colormap bone

figure('position',P5);
figure(5);
%spectrogram(x,window,noverlap,f,fs)
spectrogram(y,256);
text(0.4,28,'Frame Size 256','FontSize',12);

figure('position',P6);
figure(6);
%spectrogram(x,window,noverlap,f,fs)
spectrogram(y,512);
text(0.4,28,'Frame Size 512','FontSize',12);
```   ## Play back block

```soundsc(y,Fs);
```

## Screen Display Settings

```%Measure Screen Size of the device
%Calculate position values of figure windows
scrsz = get(0,'ScreenSize');
P1 = [50 500 scrsz(3)/3 scrsz(4)/3];
P2 = [50 80 scrsz(3)/3 scrsz(4)/3];
P3 = [500 500 scrsz(3)/1.5 scrsz(4)/3];
P4 = [500 80 scrsz(3)/1.5 scrsz(4)/1.5];
```

## Generate Basic Signals

```figure('position', P4);
figure(1);
```

## Sine Wave

```t = 0:(1/1000):1;
x1 = sin(2*pi*1*t) ;
subplot(4,2,1);
plot(x1);
grid on
title('Sine Wave');
xlabel('Samples');
ylabel('Amplitude');

y1 = xcorr(x1,x1);
subplot(4,2,2);
plot(y1);
grid on
title('Sine Wave Autocorr');
xlabel('Samples');
ylabel('Amplitude');
``` ## Ramp

```x2 = t;
subplot(4,2,3);
plot(t);
grid on
title('Ramp');
xlabel('Samples');
ylabel('Amplitude');

y2 = xcorr(x2,x2);
subplot(4,2,4);
plot(y2);
grid on
title('Ramp Autocorr');
xlabel('Samples');
ylabel('Amplitude');
``` ## Rectangular

```x3 = ones(1,1500);
subplot(4,2,5);
plot(x3);
grid on
title('Rectangular');
xlabel('Samples');
ylabel('Amplitude');

y3 = xcorr(x3,x3);
subplot(4,2,6);
plot(y3);
grid on
title('Rect Autocorr');
xlabel('Samples');
ylabel('Amplitude');
``` ## 1 minus x^2

```x4 = 1- t.*t;
subplot(4,2,7);
plot(x4);
grid on
title('XSquare');
xlabel('Samples');
ylabel('Amplitude');

y4 = xcorr(x4,x4);
subplot(4,2,8);
plot(y4);
grid on
title('XSquare Autocorr');
xlabel('Samples');
ylabel('Amplitude');
``` ## 19/05/2015 6:00 PM 'C:\Users\SAJIL\Documents\MATLAB\Seachannel.m'

```%Version 1.0
%Sajil C. K., DCB, Uok.
%sajildcb@gmail.com
%This program Reads a speech wav file from Hard disk, then its applied
%though transformations in whcin it is attenuated and is affected by
%Gaussian noise. We can hear to the effects of these after each steps
```

## Screen Display Specifications

```%Measure screen size of PC
%Calculate position values of figure Windows

scrsz = get(0,'ScreenSize');
P1=[40 500 scrsz(3)/3 scrsz(4)/3];
P2=[40 80 scrsz(3)/3 scrsz(4)/3];
P3=[600 500 scrsz(3)/3 scrsz(4)/3];
P4=[600 80 scrsz(3)/3 scrsz(4)/3];
P5=[1000 500 scrsz(3)/3 scrsz(4)/3];
P6=[1000 80 scrsz(3)/3 scrsz(4)/3];
P =[P1;P2;P3;P4;P5;P6];
c=['m' 'c' 'r' 'g' 'b' 'k'];
```

```[x, Fs] = audioread('I Love You Daddy.wav');
N=length(x);
t=(0:(N-1))'/Fs;
```

## Parameter specifications

```A = 0.5; %Channel attenuation value
G = 6; %Specify Number of Gate Breaks here
i = 1;
```

## Channel Model

```while i<=G
```

## Plot Signal

```    figure('position', P(i,:));
figure(i);
plot(t,x,c(i));
grid on
title(strcat('Transmitted Signal at Gate ', num2str(i)));
xlabel('Time in Seconds');
ylabel('Amplitude');
legend(strcat('Speech @ Gate ',num2str(i)));
```      ## Play back of Original

```    p= audioplayer(x,Fs);
play(p);
pause(max(size(x))/Fs);
```

## Generate Guassian Noise Model

```    n= 0.5*rand(N,1)-0.5;
```

## Signal Attenuation and Noise

```    x=x*A;
x=x+n;
i=i+1;
```
```end
```

## Screen Display Specifications

```%Measure screen size of the device
%Calculate position values of figure Windows

scrsz = get(0,'ScreenSize');
P1=[40 500 scrsz(3)/3 scrsz(4)/3];
P2=[40 80 scrsz(3)/3 scrsz(4)/3];
```

## Read Room Impulse Response File

```[x1,Fs1]=audioread('tunnel_balloon_441k.wav');

x1=x1(:,1);
x2=x2(:,1);
```

## Plot Impulse Response of Tunnel

```figure('position', P1);
figure(1);
plot(x1,'k');
grid on
title('IR of tunnel balloon 441k.wav');
xlabel('Samples');
ylabel('Amplitude');
legend('tunnel IR');
``` ## Plot Impulse Response of Underground Carpark

```figure('position', P2);
figure(2);
plot(x2,'r');
grid on
title('carpark balloon 441k.wav');
xlabel('Samples');
ylabel('Amplitude');
legend('Carpark IR');
``` ```[y,Fs2]=audioread('Asianet.wav');
y=y(:,1);
```

## Perform Convolution

```o1 = conv(x1,y);
o2 = conv(x2,y);
```

## Playback the Output Signal

```%soundsc(o1,Fs1);
%soundsc(o2,Fs1);
```