SounBum Song
SounBum Song

Reputation: 255

YIN algorithm to python for finding fundamental frequency

I am trying to find fundamental frequency with YIN algorithm in python.

I am at step 2 of this document.

I need to find index of 0 value from this code:

def auto(t, lag, samples):
    total_index = len(samples)
    zero_padded = np.append(samples, np.zeros(total_index))

    r = 0
    for j in range(t+1, t+total_index):
        r += zero_padded[j] * zero_padded[j+lag]

    return r

diff = []
rt0 = auto(0, 0, samples)
for lag in range(0, 2700):
    diff.append(rt0 + auto(lag, 0, samples) - (2*auto(0, lag, samples)))

as mentioned in document:

enter image description here

enter image description here

but I cannot find any 0 value index except index(lag) = 0.

enter image description here

  1. what codes should be fixed?

and the document said they did cumulative mean to nomalize.

  1. what is cumulative mean nomalization?

Upvotes: 2

Views: 1035

Answers (1)

hotpaw2
hotpaw2

Reputation: 70663

Typically, one ignores the AMDF result with a lag at or near zero, and looks for a non-zero AMDF lag with a small but usually non-zero difference. Which non-zero AMDF to select is known as the octave problem, and may involve weighting the difference function.

Upvotes: 2

Related Questions