Home > Archive > Matlab > June 2007 > Can someone help with Fast Fourier Transforms for getting Pitch?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Can someone help with Fast Fourier Transforms for getting Pitch?
|
|
| JimmyR.com 2007-06-19, 10:14 pm |
| I recorded a 16000hz / 1 second audio sample of me singing a pitch
~174.61 (F3). I need help getting matlab to detect the pitch.
I converted each audio sample into an integer 0 - 255 and saved it to
dat.txt.
http://www.buildquiz.com/dat.zip (9 kb)
I used the example FFT for spectral analysis demo and tried to modify
it to work with a 16,000hz file but I was very unsuccessful.
// .0000625 second per audio sample or 1 second / 16,000
t = .0000625:.0000625:1;
// I import dat.txt (from the dat.zip link above) into the matlab
variable x.
x= ...
// Shows the audio file exactly as it appeared in my audio recorder.
plot (t,x);
// The fast fourier transforms. I don't understand why they used 256
in the demo when the audio samples were 251
Y = fft(y,16000);
I'm not going to guess what to do next. The demo says....
Pyy = Y.*conj(Y)/256;
f = 1000/256*(0:127);
plot(f,Pyy(1:128))
title('Power spectral density')
xlabel('Frequency (Hz)')
I know it's a lot but can anyone help complete these last few lines so
it detects my pitch? I don' understand them.
| |
| Srikanth 2007-06-20, 8:14 am |
| The maxima of the ACF function occurs at the pitch period - you could
use that... the fft of the acf is the psd. And i guess that the pitch
freq will turn out to be a maxima in the psd...
If you don't want to do Acf in time, you need to find out which freq
the maximum sample in the freq domain relates to. That is what the
last part does - it gives the frequency values in Hz on the x axis,
instead of samples..FFT ranges from 0 to Fs, and is symmetric... if
you have N samples in your fft, each sample corresponds to a change Fs/
N... since the freq domain is symmetric, the author plotted only the
first 128 values, while the freq scale goes from 0 to (127)Fs/N in
steps of Fs/N (f = 1000/256*(0:127); )... I take it that 1000 was the
Fs in the demo...You need to make it 16k, and change the nr of samples
based on ur system...
of course, you could do the whole thing in time domain using acf
HTH
Srikanth
|
|
|
|
|