how can the noise be removed from a recorded sound,using fft in MATLAB?

前端 未结 2 769
迷失自我
迷失自我 2021-02-01 11:33

I want to remove noises from a recorded sound and make the fft of it finding fundamental frequencies of that sound, but I don\'t know how to remove those noises. I\'m recording

2条回答
  •  -上瘾入骨i
    2021-02-01 12:10

    Saying that there is noise in your signal is very vague and doesn't convey much information at all. Some of the questions are:

    • Is the noise high frequency or low frequency?
    • Is it well separated from your signal's frequency band or is it mixed in?
    • Does the noise follow a statistical model? Can it be described as a stationary process?
    • Is the noise another deterministic interfering signal?

    The approach you take will certainly depend on the answers to the above questions.

    However, from the experiment setup that you described, my guess is that your noise is just a background noise, that in most cases, can be approximated to be white in nature. White noise refers to a statistical noise model that has a constant power at all frequencies.

    The simplest approach will be to use a low pass filter or a band pass filter to retain only those frequencies that you are interested in (a quick look at the frequency spectrum should reveal this, if you do not know it already). In a previous answer of mine, to a related question on filtering using MATLAB, I provide examples of creating low-pass filters and common pitfalls. You can probably read through that and see if it helps you.

    A simple example:

    Consider a sinusoid with a frequency of 50 Hz, sampled at 1000 Hz. To that, I add Gaussian white noise such that the SNR is ~ -6dB. The original signal and the noisy signal can be seen in the top row of the figure below (only 50 samples are shown). As you can see, it almost looks as if there is no hope with the noisy signal as all structure seems to have been destroyed. However, taking an FFT, reveals the buried sinusoid (shown in the bottom row)

    enter image description here

    Filtering the noisy signal with a narrow band filter from 48 to 52 Hz, gives us a "cleaned" signal. There will of course be some loss in amplitude due to the noise. However, the signal has been retrieved from what looked like a lost cause at first.

    enter image description here

    How you proceed depends on your exact application. But I hope this helped you understand some of the basics of noise filtering.

    EDIT

    @Shabnam: It's been nearly 50 comments, and I really do not see you making any effort to understand or at the very least, try things on your own. You really should learn to read the documentation and learn the concepts and try it instead of running back for every single error. Anyway, please try the following (modified from your code) and show the output in the comments.

    [y,fs]=wavread('100cmfreefall.wav');
    ch1=y(:,1);
    time=(1/fs)*length(ch1);
    t=linspace(0,time,length(ch1));
    L=length(ch1);
    NFFT = 2^nextpow2(L);
    f = fs/2*linspace(0,1,NFFT/2+1);
    
    [b,a]=butter(10,3e3/(fs/2),'high'); 
    y1=filtfilt(b,a,ch1);
    
    figure(1)
    subplot(2,1,1)
    Y=fft(ch1,NFFT)/L;
    plot(f,log10(abs(Y(1:NFFT/2+1))))
    title('unfiltered')
    
    subplot(2,1,2)
    Y1=fft(y1,NFFT)/L;
    plot(f,log10(abs(Y1(1:NFFT/2+1))))
    title('filtered')
    

提交回复
热议问题