One idea would be to make "midiparse" and "midiformat" objects for Pd. Zack Settel wrote a version of this for Max once long ago.