Using xcorr in pitch detections
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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?
0 comentarios
Respuesta aceptada
Daniel Shub
el 22 de Ag. de 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 comentarios
Daniel Shub
el 24 de Mayo de 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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Measurements and Spatial Audio en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!