Pitch is periodicity. The detector looks for the shift at which the waveform best matches a delayed copy of itself, and the length of that shift is the period.
YIN, not plain autocorrelation
Raw autocorrelation is always largest at zero lag, so a naive search reports whatever the smallest allowed shift is. YIN uses a difference function instead, then divides each value by the running mean of everything before it. That normalisation is what stops the reading from collapsing to the top of the range, and it is why octave errors are the exception here rather than the rule.
The chosen minimum is refined by fitting a parabola through its neighbours, which gets the frequency well inside a cent even though the shift itself is a whole sample.
The pitch track
The plot puts time on the horizontal axis and pitch on a semitone grid, so a drift of one tone looks the same anywhere on the range. Octave lines are labelled.
A steady note draws a flat line. Vibrato draws a ripple. A slide draws a ramp. A gap means nothing periodic was found.
Median rather than mean
The headline figure is the median of the voiced readings. A mean would be dragged by the octave errors and the transitions between notes; a median ignores both.
For a single sustained note the two agree. For a melody the median tells you the centre of the range, which is not the same as the note the piece is in.
Cost on a long file
The signal is decimated to roughly 12 kHz before analysis, since pitch lives far below that and the difference function is quadratic in the window length. Readings are then spaced by the file’s own duration, so a three minute take and a three hour one produce about the same number of points.
Chords report a note nobody played
Feed it a C major triad and it reports 65 Hz. That is not a bug and it is not the loudest note: 261.63, 329.63 and 392 Hz all divide into roughly 65.4 Hz, so the summed waveform genuinely repeats at C2. Periodicity is what the method measures, and a chord is periodic at the pitch its notes have in common.
This is the same effect that lets a small speaker suggest a bass note it cannot reproduce. It is also why the tool is only useful one voice at a time.
Where else it fails
Heavily distorted guitar has a fundamental that is often quieter than its harmonics. Whispered speech has no fundamental at all. Anything below 55 Hz or above 1500 Hz is outside the search range and reads as the nearest thing inside it.