# Hello I am currently working on a project which involves the analysis of an input sound signal and gives the instantaneous frequency at every point on the signal. I am looking to apply a ideal hig pass filter to remove the external noises. Need help.

4 views (last 30 days)
Answered: David Ding on 17 Oct 2017
if true
%In this code first i recorded the sound in using the matlab sound recorder
%Then i performed the opertions on the recorded signals data and with the
%plotted graph of this operation i tried to apply the fft analysis for
%finding the frequency at every point of the signal.
%Step 1- soung signal recording
clear all;
close all;
speaker11 = audiorecorder(44100,16,1);
fs=44100;
disp('Start Speaking');
pause(0.1);
recordblocking(speaker11,5);
disp('End of the recording');
play(speaker11);
y=getaudiodata(speaker11);
audiowrite(filename,y,Fs);
%plot the graph of the signal input
figure(1)
plot(y)
%Apply a small signal linear filte to remove unwanted high amplitudes.
s=filter([1-.95],1,y);
figure(2)
plot(s)
N=256;
%Applying framing to convert the signal to a several discrete frames
Number_of_frames= round(5*Fs/256);
for K=1 : size(s,2)
y1{K}= buffer(s(:,K),256,35);
figure(3)
plot(y1{K})
end
%Fft of the resulting function
n=256;
f=Fs/N.*(0:N-1);
y3=fft(s,n);
y3=abs(y3(1:n)./(n/2));
figure(4)
plot(f,y3)
grid on
[a,b]=ginput();
disp([a b])
%The idea was that the average of all the fft values to be close to the
%input frequency. However for the input of 440Hz i was getting an average value of
%around 480. Thus i wanted to know how to apply a suitable high pass filter
%to reduce the external noises.
end

David Ding on 17 Oct 2017
Hi Firoz,
I understand you are looking for a way to implement an ideal High Pass Filter (HPF) to your signal to remove noises. While I am not in a position to suggest specifications of such filter, I would like to refer you to our very useful "designfilt" function which can design filters, including HPFs, based on your specifications. Examples below:
Documentation page for the "designfilt" function:
Cheers,
David