title: Remove noise on a wav file
body: <p>I'm working on a small code to learn signal processing on Matlab. I have got a .wav sound with some noise and I just want to remove the noise. I tried the code under but noise is not removed correctly. My idea is to do a cut band filter to remove the different noise components on the fft. After a lot of researches, I don't understant where is my problem. Here my code :</p>
  
  <pre><code>clear all;
  clc;
  close all;
  
  % We load and plot the signal
  [sig,Fs] = audioread('11.wav');
  
  N = length(sig);
  
  figure,plot(sig); title 'signal'
  
  % FFT of the signal
  fft_sig = abs(fft(sig)); 
  
  % Normalisation of the frequencies for the plot
  k = 0 : length(sig) - 1;  
  f = k*Fs/length(sig);
  
  plot(f,fft_sig);
  
  % Loop with 2 elements because there are 2 amplitudes (not sure about
  % this)
   for i = 1:2
  
  % I put noise components in an array
  [y(i),x(i)] = max(fft_sig);
  
  % Normalisation of the frequencies to eliminate
  f(i) =  x(i) * (Fs/N);
  
  % Cut band filter with elimination of f from f-20 to f+20 Hz
  b = fir1(2 , 2 * [f(i)-20 f(i)+20] / Fs, 'stop')
  
  sig = filter(b,1,sig);
  
  figure,plot(abs(fft(sig)));title 'fft of the signal'
  
  end
  </code></pre>
  
  <p>Here the images I got, the fft plot is exactly the same before and after applying the filter, there is a modification only on the x axis :</p>
  
  <p><a href="https://i.stack.imgur.com/pUrwX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pUrwX.png" alt="enter image description here"></a> </p>
  
  <p><a href="https://i.stack.imgur.com/d5JoP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/d5JoP.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/bDTN3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bDTN3.png" alt="enter image description here"></a></p>
  
  <p>The sampling frequency is Fs = 22050.</p>
  
  <p>Thanks in advance for your help, I hope I'm clear enough in my description</p>