Okay, so the code is not that complicated.

The core is basically these three lines In which

we defined the deviation from perfect harmonicity.

So we find the peaks compare or

a particular peak compared with a particular perfect harmonic.

We also compared a peak with respect to the previous harmonic

coming from the previous frame.

And then, we define the threshold base

on these harmonic deviation of slope that is the one that will be accepted.

So if the current peak is within that threshold therefore,

within the kind of vertical deviation and horizontal deviation,

so it has this frequency and time evolution tracking.

So we accept that peak as harmonic and

we keep adding to the harmonic that we create and that's all,

that's basically what the harmonic detection does.

So if we go back to the harmonic model now [COUGH] after this harmonic detection.

Let's say this is a setup some code to create the array of values that

keep adding up to the whole matrix of the output.

And finally, if once the whole process is done, so

once we have gone through the whole sound.

We clean the tracks, so

we delete the tracks that are smaller than a given duration,

and again, this is the same then with it in the sinusoidal analysis.

Okay, so I wrote a script that basically analyzes

a sound with this harmonic model and now function,

so we took this vignette sound and specified all the parameters.

So the number of parameters are starting to get quite a few.

So we have the window, we have the window size, the FFT size, the threshold.

There is no need for this comma here, so minus 90 as a threshold,

then minimum duration in time, the number of maximum number of harmonics.

The minimum fundamental frequency and

maximum fundamental frequency, the errors threshold that we accept and

then this deviation slope that we just talked about.

Then there is these two parameters that are normally fake because they

are more related to synthesis which is the FFT of the synthesis buffer.

And the hop size which are given that the FFT buffer requires for

the synthesis, it requires the hop size to be one-fourth of that.

So we normally put H as being 128, so

we normally don't allow any changes from that.

So from the graphical interface, there is no control over these two parameters.

Okay, and then we read the sound, we get the window and

we call this harmonic model an function.

And here, I just plot the frequencies of these trajectories, so let's run this.

So let's run test three, now let's first save it.

Okay, and now let's run it.

Okay and this is the trajectories we obtained,

okay they are okay, they're pretty good.

If we zoom in into a particular region,

we might be able to see a little more, okay?

Of course, if we zoom in we're starting to see

the problems at the transitions between nodes.

And especially, we see a problem as the harmonics go higher and higher up.

This is because this is a linear scale and

this deviations are kind of logarithmic.

So as the frequency goes up, in fact the changes

get much larger because they are logarithmic changes.

So in fact,

this is the reason why we need this deviation slope that we specified here.

So for example, if we reduce this deviation slope,

let's make instead of 0.01.

Let's make 0.001 and let's run it again.