Extracting the fundamental frequency of a .wav file

조회 수: 12 (최근 30일)
Rosano Rosano Sánchez
Rosano Rosano Sánchez 2012년 10월 19일
편집: Mohit Motwani 2020년 11월 2일
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