How can i determine the dominant frequency of a real sound signal recorded from microphone dirctly to matlab

2 vues (au cours des 30 derniers jours)
I want to plot the line spectra of a sound data recorded from microphone in wav format
I am not sure whether this code gives the right value or not
function line_spectra(z,Fs);
clear all
close all
clc
clf
%Initialize variab
[z,Fs] = wavread(normal_1.wav',2^17);Fs=44100Hz,data sample=131072
N=length(z);
b=bin2dec(fliplr(dec2bin(0:N-1)))+1;
%make it bit reversed order
MC=z(b);
alfa=N/2;
beta=1;
%calculate Twiddle factor
for n=1:N/2
W(n)=exp(-1i*2*pi*(n-1)/N);
Wr(n)=cos(2*pi*(n-1)/N);
Wi(n)=-sin(2*pi*(n-1)/N);
end
%calculate FFT using inplace non-recursive FFT,radix-2
for h=1:(log(N)/log(2));
b=2^(h-1);
a=1;
a0=1;
for d=1:alfa
c=1;
for e=1:beta
temp1=W(c)*MC(a+b);
temp2=MC(a);
MC(a)= MC(a)+temp1;
MC(a+b)=temp2-temp1;
a=a+1;
c=c+alfa;
end
a=a0+2^(h);
a0=a;
end
alfa=alfa/2;
beta=beta*2;
end
s=which('Exh_manifold_T3B.wav');%Modifying the figure window
set(gcf,'color',get(0,'DefaultUIcontrolBackgroundColor'),'NumberTitle',...
'off','Name',s,'Resize','on','Menubar','none');
%calculate the frequency
fr = (0:(N/256)-1)*Fs/N;
%plot the figure
p = abs(MC(1:N/256));
[Amax,f] = max(p);
fprintf('Max.Magn. of Amp1. is %6.4f db/n and the freq f is %4.2f\n',Amax,f);
pp=fftshift(p);
plot(fr,pp,'k')
xlabel('Frequency(Hz','Color','k','FontSize',12);
ylabel('Magnitude','color','k','FontSize',12);
title('Line spectrum plot for defective engine sound ','color','k','FontSize',12);
set(text (170,1660,'Background','b','EdgeColor','r'),'color','k','FontSize',12);
QUESTION
  1. fail to determine the fundamental frequency .
  2. How can I filter it
  3. the reading directly from the plot and from the code p = abs(MC(1:N/256));
[Amax,f] = max(p);
fprintf('Max.Magn. of Amp1. is %6.4f db/n and the freq f is %4.2f\n',Amax,f); not the same
  4 commentaires
Rick Rosson
Rick Rosson le 11 Août 2014
Why did you create your own implementation of the FFT? Why not use the fft function included in MATLAB?
TESFAW
TESFAW le 11 Août 2014
I do not know where and when the
fft() is used, Sir! plz help me

Connectez-vous pour commenter.

Réponse acceptée

Image Analyst
Image Analyst le 11 Août 2014
How about you just call fft() and look for the location (frequency) of the maximum value? Looks like you're doing that - was there any problem with it?
  1 commentaire
TESFAW
TESFAW le 11 Août 2014
Yes,Sir!
the reading from the plot and the value displayed into the
command window is not the same.
I do not know why ...
I think the problem is in my code but I do not know which
one is wrong

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Audio Processing Algorithm Design dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by