Using xcorr in pitch detections

6 Ansichten (letzte 30 Tage)
Robert
Robert am 21 Aug. 2011
I'm currently switching from fft to this function and I found some questions. What I have known is that we should calculate the frequency through comparing the positons of adjacent local maxima, but I don't know how I should use my maxima. I'm testing things with a 120Hz sine wave:
t=(0:999)*(1/1000); x = sin(2*pi*120*t); R = xcorr(x); [pks,locs]=findpeaks( R );
the locs have differences of 8 or 9, which is still correct ( 1/(9/1000) < 120 < 1/(8/1000) )
But I don't know how to get 120 as my answer using effective codes.
How much maxima should I count into the average value, etc?
And I don't think my code works with mixed frequencies... Can someone give me a direction?

Akzeptierte Antwort

Daniel Shub
Daniel Shub am 22 Aug. 2011
Pitch detection is a huge field with many different algorithms each with advantages and disadvantages. How close to 120 do you need to get. What i your answer is 121, 120.1, 120.01, ...
One easy way to get around the problem is to increase your sampling rate.
Fs = 1e6;
t=(0:(Fs-1))*(1/Fs);
x = sin(2*pi*120*t);
R = xcorr(x);
[pks,locs]=findpeaks(R);
[min(Fs./diff(locs)), mean(Fs./diff(locs)), max(Fs./diff(locs))]
ans =
119.9904 120.0000 120.0048
  6 Kommentare
Daniel Shub
Daniel Shub am 24 Mai 2012
That is a lot of questions. Why don't you try and implement something with this code and see where you get stuck. Also if the answer is helpful, consider voting for it.
Farideh Jalali
Farideh Jalali am 27 Mai 2012
Thanks.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Measurements and Spatial Audio finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by