The fundamental frequency fo is the main component of the pitch. However, it is difficult to build a reliable note detction algorithm involving fundamental frequency because of pitch estimation errors and the effect of the harmonics. Thus, a reliable pitch detection algorithm is a very important component in our system. AMDF stands for Average Magnitude Difference Function and it is avariation of autocorrelation analysis for measuring the periodicity of voiced speech and music signals. The autocorrelation method to estimate pitch is based on detecting the highest value of the autocorrelation function in the region of interest. Given a discrete time signal x(n), defined for all n , the auto-correlation function is defined as
For pitch detection, if we assume x(n) is periodic with period P, i.e., x(n) = x(n + P) for all n, then it is shown that the autocorrelation is also periodic with the same period.
However, for the signals acquired from the musical recordings it is we must define a short-time autocorrelation function, which operates on short segments of the signal also called window (Used for the spectrograms).
With AMDF, instead of correlating the input signal at various delays as done with the correlation, where we must do multiplications and summations at each value of delay, a difference signal is formed between the delayed speech and the original. At each delay, the absolute magnitude of the difference is taken.
Thus, Dm, is a difference signal formed by delaying the input speech various amounts m, subtracting the delayed waveform from the original, and summing the magnitude of the differences between sample values.
If x(n) is a periodic signal of period P, the difference function x(n)-x(n-m) will be approximately zero for m=0,±P,±2P... Because the signals we are measuring are quasiperiodic, the difference function will be small for m=0,±P,±2P...
The pitch period is identified as the value of the lag which the minimum AMDF occurs, so the main frequency is the one that corresponds to that period.
With this method we have obtained the best note identification results, which are shown in the following image.
With these tools we have implemented the following algorithm for pitch detection: