Search code examples
matlabwavnoise-reduction

How to remove the noise from a wav file with a IIR Eliptical filter


I have to remove the noise from a wav music file with matlab.

I know that I have to use the ellipord and ellip functions. First I read the wav file:[x,Fs]=wavread('file.wav');

Then I do a spectrogram: spectrogram(x,512,400,512,Fs,'yaxis');

enter image description here

Now, I can't understand some things:

  • I have to remove that red line? (I suppose that's the noise)
  • What is the Wp value on the ellipord function? (I know it calls passband corner frequency).
  • The Ws value will be something like between 14000 and 16000 hz? It's value to remove the noise? How can I figure it out the values of Wp, Ws, Rs and Rp looking to this spectrogram?

Solution

  • Your noise looks like high frequency hiss at 15000 Hz. I think the best way to remove this noise is a bandstop filter, though it is hard to say without listening, maybe a lowpass filter will fit your requirements better. I'd try other filter types as well

    Fs = 44100;
    %what frequencies do you want to pass
    wp = [12000 18000] / (Fs/2);
    %what frequencies you don't want to pass
    ws = [14000 16000] / (Fs/2);
    %ellipsoid filter characteristics must be smooth
    %so you have to select how many decibels 
    %you allow to lose at passband (i.e. 12000 and 18000 hz)
    rp = 3;
    %stopband (minus decibels at 14000 and 16000 hz)
    rs = 60;
    [n,Wp] = ellipord(wp,ws,rp,rs)
    [b,a] = ellip(n,rp,rs,wp,'stop');
    freqz(b,a,Fs,Fs);