Using xcorr in pitch detections
Show older comments
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?
Accepted Answer
More Answers (0)
Categories
Find more on Measurements and Spatial Audio in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!