Difference between revisions of "Tuner Upper Removal Demonstration"
From Class Wiki
Brian.Clark (talk  contribs) 

(2 intermediate revisions by 2 users not shown)  
Line 1:  Line 1:  
−  % Demonstration of LMS algorithm for noise cancellation. 

+  <nowiki> 

−  % Rich Kozick, Spring 1997 

+  % Demonstration of LMS algorithm for noise cancellation. Tuner upper problem. 

−  % Rob Frohne's modifications for Macintosh 2000. 

+  % Rich Kozick, Spring 1997 

−  % Desired signal 

+  % Rob Frohne's modifications for Macintosh 2000 

−  clear all 

+  % and Linux 2006 or so. 

−  Totaltime=1; 

+  
−  speak('Hit a key and speak the signal.'); 

+  
−  pause; 

+  clear all 

−  [st, Fs] = recordsound(Totaltime, 22050, 1); 

+  Fs=8000; % 8 Khz sampling for Linux. 

−  s = st'; 

+  T0 = 2; % 2 seconds 

−  Ls = length(s); 

+  
−  % Interference + random noise 

+  system("espeak 'After hitting enter in the command window, speak the signal.'"); 

−  speak('Hit a key and make the noise!'); 

+  st = record(T0,Fs); 

−  pause; 

+  %st=wavread('Hello.wav'); 

−  [nt,Fs] = recordsound(Totaltime, 22050, 1); 

+  st=st(:,1); 

−  n = nt'; 

+  
−  %Sign = 0.01; 

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

−  %Dn=20; % Delay of the noise that appears in y. 

+  soundsc(st); 

−  %n = n(1:Ls) + Sign*randn(Ls,1); 

+  
−  %an = [0 .01 .5 1 .5 .1 .01 0]; 

+  Ls = length(st); 

−  an = 4*[0 0 0 0 0 0 0 0 0 0 0 0 0 0 .5 1 .5]; 

+  T0=length(st)/Fs; 

−  bn = [1]; 

+  % Make the tuner upper noise or even several at the same time. 

−  +  t=0:1/Fs:T01/Fs; 

−  +  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.'") 

−  +  soundsc(x,Fs); 

−  +  
−  +  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:(kN+1)); 

−  +  y(k) = h'*xk'; 

−  +  e(k) = y(k); 

−  +  h = h  2*mu*e(k)*xk'/(xk*xk'); 

−  +  end 

−  +  
−  +  % The signal estimate is in the vector e 

−  +  system("espeak 'Here is a scaled version of the tail of the cleaned signal.'"); 

+  skip =1000; 

+  soundsc(e(skip:length(e)),Fs); 

+  </nowiki> 
Latest revision as of 14:43, 6 December 2015
% 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); %st=wavread('Hello.wav'); st=st(:,1); system("espeak 'Here is the signal.'") soundsc(st); Ls = length(st); T0=length(st)/Fs; % Make the tuner upper noise or even several at the same time. t=0:1/Fs:T01/Fs; 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.'") soundsc(x,Fs); 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:(kN+1)); y(k) = h'*xk'; e(k) = y(k); h = h  2*mu*e(k)*xk'/(xk*xk'); end % The signal estimate is in the vector e system("espeak 'Here is a scaled version of the tail of the cleaned signal.'"); skip =1000; soundsc(e(skip:length(e)),Fs);