Tuner Upper Removal Demonstration

From Class Wiki
Jump to: navigation, search
% Demonstration of LMS algorithm for noise cancellation.  Tuner upper problem.
% Rich Kozick, Spring 1997
% Rob Frohne's  modifications for Macintosh 2000
% and Linux 2006 or so.

clear all
Fs=8000; % 8 Khz sampling for Linux.
T0 = 2;  % 2 seconds

system("espeak 'After hitting enter in the command window, speak the signal.'");
st = record(T0,Fs);

system("espeak 'Here is the signal.'")

Ls = length(st);
%  Make the tuner upper noise or even several at the same time.
n =  10*(sin(2*pi*100*pi*t) + cos(2*pi*600*t) + 1.5*sin(2*pi*850*t));

% Add him or them to the desired signal.
x = st' + n;

system("espeak 'Here is the noisy signal.'")

N = 64;         % Length of adaptive filter

% LMS algorithm for adaptive noise cancellation

h = ones(N,1);
mu = 0.1;
for k=N:Ls
  xk = x(k:-1:(k-N+1));
  y(k) = h'*xk';
  e(k) = y(k);
  h = h - 2*mu*e(k)*xk'/(xk*xk');

% The signal estimate is in the vector e
system("espeak 'Here is a scaled version of the tail of the cleaned signal.'");
skip =1000;