FINALLY finished MIDI_encode. Needs comments though

PLEASE GOD WORK