This is a pretty complicated process and unless we stick to talking about step 6 only, I think your question is too broad. So I'm only going to talk about step 6.
The challenge that step 6 is meant to address is the following: There is not a fixed correlation between pitch and frequency. A frequency is a primarily scientific concept. When there is a musical sound played or recorded, either the air or the recording medium is excited in a specific way a certain number of times per second, i.e., at specific frequencies. When human ears hear those frequencies, it can generate a sensation of a pitch (assuming the frequencies together for a certain pattern). So pitch is the brains subjective interpretation of scientifically measurable frequencies. Compare with loudness (subjective) and intensity (scientific).
Because pitch is subjective, more than one set of frequencies can be interpreted as being the same pitch by the human mind. Beyond that, in music theory, there are a finite number of discrete pitches, but frequency is a continuum. So a musician or music theorist may describe a note as being "A4" when it has a fundamental frequency of anywhere between about 425 - 450 Hz. Somehow your software has to check for that possibility and adjust its assignment of frequencies to pitches accordingly.
Now musicians do like to play together in groups, and it's going to sound terrible if one of us things that A4 is 435 Hz and another thinks A4 is 440 Hz, so for a few centuries now, we have developed reference frequencies. That just means that we agree that we are going to tune our instruments (tuning is the adjustment of what frequency is played by each nominal note the instrument plays) based around a single frequency so that we can all play together any time we want (more or less).
At this time, by far the most popular pitch reference is A4 should have a fundamental frequency of 440 Hz, and we call that "A-440". In the past, lower frequencies for A4 have been popular, such as 435 Hz. Once an instrument has been tuned to A-440, all of its notes should be related to the A4 tuning in a specific way. This table shows the fundamental frequency of each note when based on A-440 tuning.
Even though that's a standard, instruments are real-world and humans are fallible, so it's pretty much impossible for any instrument to be spot-on to the A-440 tuning for all of its notes. Even more complicated is the fact that some instruments produce frequency spectra where it's necessary to deliberately mistune certain notes in order for the "mistuned" frequencies to generate the correct pitch sensation (the piano is famous example and this mistuning is called "octave stretching").
So when your software starts decoding frequencies that do not match the A-440 frequency table, it will have to make a best guess as to what pitch sensation is intended, and assign those pitches to those frequencies. That's what step 6 is. The reason why you want to estimate the deviation from 440 Hz is if you pick up a few notes, find they don't match the table but find they are equivalently too high or too low, then you can guess that the whole instrument is in tune with itself, it just isn't properly tuned to A-440. That means you can refine your pitch assignments by expecting all of the notes from that instrument to be too high or too low by approximately the same amount.
Computing the reference frequency is finding what A4 on the given instrument is probably actually tuned to based on the frequencies decoded. For example, if you decode the frequencies of 435, 870, 1305, and 1740, you can be pretty sure that pattern was meant to be A4 that has been tuned to 435 Hz instead of 440, and that's your reference frequency for that recording.