Separated out MIDI file reading code.
added ns for non-Emacs work