Extracting the fundamental frequency of a .wav file

12 次查看(过去 30 天)
I have a .wav file, which I read with wavread and later do the fft.
If Y=fft(y,N), being y the vector with the samples of the .wav file and Y the fourier transformation of y.
How can I make a relation between the frequencies and the samples of Y? I want to get the frequency in wich Y has the highest value.
Thanks.

采纳的回答

Wayne King
Wayne King 2012-10-19
Here is an example you can modify with your input y
For even length y:
Fs = 1000;
t = 0:0.001:1-0.001;
y = cos(2*pi*100*t)+randn(size(t));
ydft = fft(y);
freq = 0:Fs/length(y):Fs/2;
ydft = ydft(1:length(y)/2+1);
plot(freq,abs(ydft))
[maxval,idx] = max(abs(ydft));
freq(idx) %this is frequency corresponding to max value
For odd length y
t = 0:0.001:1;
y = cos(2*pi*100*t)+randn(size(t));
ydft = fft(y);
freq = 0:Fs/length(y):Fs/2;
ydft = ydft(1:floor(length(y)/2)+1);
[maxval,idx] = max(abs(ydft));
freq(idx) %this is frequency corresponding to max value
  3 个评论
Marco Macedo
Marco Macedo 2020-5-28
Hello, i´m really late xD but how can i extract the frequenct of the first peak? that is the fundamental frequency
Mohit Motwani
Mohit Motwani 2020-11-2
编辑:Mohit Motwani 2020-11-2
what if I compute an n-point fft like
ydft = fft(y, 2048);
Should I still use this line?
ydft = ydft(1:2048/2);

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Spectral Measurements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by