Extracting the fundamental frequency of a .wav file

12 Ansichten (letzte 30 Tage)
Rosano Rosano Sánchez
Rosano Rosano Sánchez am 19 Okt. 2012
Bearbeitet: Mohit Motwani am 2 Nov. 2020
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.

Akzeptierte Antwort

Wayne King
Wayne King am 19 Okt. 2012
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 Kommentare
Marco Macedo
Marco Macedo am 28 Mai 2020
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 am 2 Nov. 2020
Bearbeitet: Mohit Motwani am 2 Nov. 2020
what if I compute an n-point fft like
ydft = fft(y, 2048);
Should I still use this line?
ydft = ydft(1:2048/2);

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by