How to filter frequencies from a wav file

14 views (last 30 days)
Julio Ortiz
Julio Ortiz on 11 Nov 2015
Answered: Star Strider on 11 Nov 2015
Hi, I have to clear the noise from a wav file using the Fourier Transform. My teacher gave me a code that obtains the fast Fourier Transform. I need to clear the noise of the signal and save the file without noise but I have no idea how to do that.
Here is my code:
clear all; clc
[song,Fs,bits] = wavread('vagon.wav');
%Check channels and convert to mono
if size(song,2)==2
y=zeros(size(song,1),1);
y(:)=0.5*(song(:,1)+song(:,2));
else
y=song;
end
Nsamps = length(y);
t = (1/Fs)*(1:Nsamps); %Prepare time data for plot
sound(song,Fs)
%Do Fourier Transform
yFT = fft(y);
% %Prepare plot FT
y_fft = abs(yFT); %Retain Magnitude
y_fft = y_fft(1:floor(Nsamps/2)); %Discard Half of Points
f = Fs*(0:Nsamps/2-1)/Nsamps; %Prepare freq data for plot
%Plot Sound File in Time Domain
figure
plot(t, y)
xlabel('Time (s)')
ylabel('Amplitude')
%Plot Sound File in Frequency Domain
figure
plot(f, y_fft)
xlim([0 20000])
B=1;
if(A>1) B=A; end
ylim([0 max(y_fft)*B])
xlabel('Frequency (Hz)')
ylabel('Amplitude')
I hope you can help me, I don't want you to do my homework, I just want to know a way to do it, I'm new to Matlab so I don't know how does it work.

Answers (1)

Star Strider
Star Strider on 11 Nov 2015
I encourage you to read through the documentation on filters and related functions in the Signal Processing Toolbox. I summarised my filter design procedure here. That should help you get started.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!