Naser.Sadeghi
Naser.Sadeghi

Reputation: 1302

How can I filter noise in an audio file using FIR filter in MATLAB?

I just have a .wav file and I have added white Gaussian Noise to it using the code below:

%Reading the audio file
[originalAudio,Fs] = audioread('/Users/.../sound.wav');
%Adding white Guassian noise to the audio file
SNR = 20;
noisyAudio=awgn(originalAudio,SNR,'measured');
%sound(noisyAudio,Fs);

I want to remove the noise using FIR filter I tried the codes below for Convolution Filter.

 outputAudio = conv2(noisyAudio,noisyAudio,'same');

Is there a builtin function like this for doing the FIR filtering in Matlab?

Upvotes: 0

Views: 1057

Answers (1)

dmedine
dmedine

Reputation: 1565

This may not be the answer you are looking for, but if you want to do FIR filtering in matlab using built in functions, you can use fir1 (or any of the other filter design functions) to generate filter coefficients, then filter to do the convolution. Digital filtering using LTI systems is by definition a convolution operation.

>> b = fir1(40, .5); % generate 40th order lowpass FIR filter at half the nyquist
>> filteredAudio = filter(b, 1, noisyAudio); % since this is FIR, the only feedback coefficient is 1 at y_n

But, this will not remove white noise. It will only attenuate frequencies (including those in the original audio signal) below half the nyquist frequency. Filtering is not the same thing as de-noising. However, convolving the noisy signal with itself isn't going to de-noise it either.

Upvotes: 3

Related Questions