Every musical note has pitch, which corresponds to the frequency of main tone.
Modern musical scale has almost 100 pitches with frequencies from approximately 30 hertz to 4,5 kilohertz. There are other scales too, but they are rarely used. Now there are two different algorithms implementing this step, each of them has its own advantages and disadvantages. The final step is producing the MIDI file structure, and you can choose some attributes of the output MIDI file. Nowadays investigations of more complex schemes are taking place, it seems that they will allow to differentiate musical instruments and make fewer errors.