0
\$\begingroup\$

I'm having trouble figuring out how to pass a signal into a low pass filter using MATLAB.

I am given a .wav file and am following instructions on how to remove high frequency noise compenents from taking the Discrete Fourier Transform(DFT) of the audio signal. The idea is that there is a secret message in the .wav file that is currently being hidden by a lot of unwanted frequency noise. I am supposed to get rid of said noise.

My script is currently as follows:
[y, Fs] = audioread('horrible_noise.wav');
y = y(:.1);
plot(y) NFFT = length(y);                             % number of discrete points
Y = fftshift(fft(y,NFFT));                               % DFT of the audio signal
F = ((-1:2/NFFT:1-2/NFFT)*Fs);                 % Range of the frequency of the audio file
magnitude_Y = abs(Y);                                % Magnitude of DFT
phase_Y = unwrap(angle(Y));                      % Phase of DFT

I'm supposed to plot the magnitude and phase and explain any trends in the plots.

plot(magnitude_Y,F)
plot(phase_Y,F)

At this point, I am supposed to remove the high-frequency components that are unwanted by setting them to zero. Which is apparently done via low-pass filtering. This is where I am having trouble. I have seeked help on this and came across commands such as using butter, fft, etc. I have no idea how to use those functions and don't even know if that is the right way of approaching my problem.

So again, I would like help on passing this signal(DFT) into a low-pass filter to get rid of unwanted noise. Thanks.

Audio signal in question - Warning, the sound isn't pleasant to listen to. Would recommend lowering your volume.

\$\endgroup\$
1
  • \$\begingroup\$ Multiple your DFT by a vector with the filter response you desire and then ifft. \$\endgroup\$
    – sstobbe
    Commented May 15, 2017 at 15:44

2 Answers 2

2
\$\begingroup\$

An FIR-filter with windowing would work well in this case. Refer to the following link to see how different orders of FIR filters (for low-pass, band-pass and high-pass) can be implemented: https://www.mathworks.com/help/signal/ref/fir1.html

The type and degree of windowing will also strongly impact the design of your low-pass filter: https://www.mathworks.com/help/signal/ug/windows.html

\$\endgroup\$
1
\$\begingroup\$

Much filtering in Matlab is done in the time domain, not the frequency domain. Taking the DFT might help to show you where your noise is, and what your filter has done, but isn't necessary.

Use the Matlab "filter" or "FIR" function. Type "help filter" at the command line, and click on the link to the documentation pages that come up if you need more help than that.

If your real question is "how do I denoise my audio file using Matlab?", I suggest asking that in the DSP group.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.