I am using YIN algorithm in a school project of mine which uses pitch detection on guitar sound. I when I play a note I get random frequencies at the beginning until they stabilize. I am thinking those are probably from action of pick on the strings.
I am going through the original paper:
Cheveigne A, Kawahara H. - YIN, a fundamental frequency estimator for speech and music
trying to reverse engineer the library and improve my results. I am studying computer science and my knowledge of signal processing is limited. A summary:
Step 1)
Auto-correlation
:- We try to find the correlation of the signal with itself shifted by a lag within a window.
Function can possibly have infinite values. We chose the highest peak with non-zero lag. Within a lag range.(Why the highest peak? Does it mean the loudest frequency?). The paper says if upper limit for $\tau$ is high. The algorithm may chose higher order peak (what are higher order peak?)
The following steps are to improve the accuracy of the results
Step 2)
Difference Function
:- Model the signal in form of a difference function.
$$ d(\tau) = \sum_{j=1}^{j=W} (x_j - x_{j+\tau})^2 $$. Which gives :
$$ d(\tau) = \sum_{j=1}^{j=W} (r_t(0) + r_{t+ \tau}(0) -2r_t(\tau)$$
So we're basically using amplitude as bias.
step 3)
Cumulative mean normalization
Replace the difference function by cumulative normalized difference to avoid selecting value with zero lag:
$$d_t(\tau')=\frac{d_t(\tau)}{(1/\tau)\sum_{j=1}^{\tau}d_t(j)}$$
step 4)
Absolute Threshold
( Could Anyone explain this section?)
step 5)
Parabolic Interpolation
: Fit the $d(\tau)$ estimates to a parabolic curve.
step 6)
Choose The Best Local Estimate
: Self explanatory
I am trying to compare guitar sound with a monophonic midi.
I think the parameters I should be thinking about tinkering with are window size and threshold to improve my results or I could discard first few frames. Could anyone point me in the right direction?
The parameters I am using :
SAMPLE RATE : 44100
WINDOW SIZE : 1024
HOP SIZE : 512
THRESHOLD : 0.1