I am trying to calculate the fundamental frequency (pitch) from autocorrelation method. Below is the figure of the signal I have.

The autocorrelation that I calculated by the following code in python is given in the picture below:

N = len(kiri) #here kiri is the input signal shown in the above pic nlags=N/2 r = np.zeros(nlags) # m=np.zeros(nlags) for lag in range(nlags): for nl in range(N - lag): r[lag] += kiri[nl] * kiri[nl + lag]

Now what I want to know is that, is the autocorrelation supposed to have zero crossings in all cases of input signals? if yes, then does that mean the abouve autocorrelation result is wrong ?

When I try to use the above autocorrelation results to calculate pitch using Mcleod Pitch Method, the NSDF function does not have zero crossings hence unable to calculate pitch. (link for reference of this method is in the comments)

Is this autocorrelation calculation method correct ? Or since the input signal itself is not exactly a periodic signal, the autocorrelation won’t have zero crossings ?

Please help.