# How do I handle harmonics for autocorrelation peaks? Need an algorithm I think.

Started by February 20, 2009
```>> there are some
>nasty problems (sub-harmonics) that you just can't get away from

I was having some problems understanding this because it is not something
I experience with my tests.  I've since read a bit about it an I understand
that it is common with certain instruments such as bells.  For the sake of
simplicity, assume that we will not have sub-harmonics.  I will limit my
pitch detector to just working for string instruments.  It is a project I
am doing for fun so it doesn't really have to capture every scenario.
Also, might as well limit it to just one note at a time.  I think the
problem becomes significantly more difficult if I add other tones so one is
enough :)

If I can find some way to manipulate the peak data in that pic I posted so
that I could obtain the fundamental frequency, then I would be all set.

I want to address the threshold idea

> With these data I'd just go for a threshold:
>
> - Decide on a threshold T
> - Find all intervals [a_m,b_m] such that r[k] > T,   k =3D [a_m,b_m]
> - Find the maximum inside each interval
> ... and there's your peaks.

I was initially finding peaks just using a threshold and taking the top
peaks.  However, my threshold was a straight horizontal line across all
samples and since the magnitude decreases the farther I get from center, it
did not work overly well.  Your method looks like it might be better but,
I don't completely understand it the way it is described above.

Can you elaborate on it a bit more? What exactly is [a_m,b_m], k =3D
[a_m,b_m], and r[k]?  I would guess that r[k]>T are peaks that are above
the threshold over the interval a_m to b_m...so I guess my question is, how
do you choose the intervals a_m to b_m (assuming there are several rather
than just 1), and do you change the threshold T for each different
interval?
```
```
noodle22 wrote:

> Hi,
>
> I am trying to determine the pitch of an audio signal using
> autocorrelation.

The standard way for doing that is the normalized autocorrelation. Start
searching for the maximum of the normalized ACF from the higher pitch
values. Assume the next maximum only if it is higher then the previous
maximum by a factor of X. X depends on the particulars of your setup and
the history.

BTW, you might need to oversample the signal for the results to be more
accurate and clear.

> So, what i'm wondering is, is there another way I can do this?

You can look for the comb period of the harmonics in the FFT domain.
This is pretty accurate.

Ah, of course, there is the ultimate pitch detector by Dmitry Teres, but
nobody knows what it is and how well it works.

DSP and Mixed Signal Design Consultant
http://www.abvolt.com
```
```noodle22 wrote:

> http://www.studypipe.com/Shared/images/Peaks.png
>
> The x axis is just sample number and it is in the time domain.

Better to call it the lag domain.

Martin

--
Quidquid latine scriptum est, altum videtur.
```