Here is the MIDI data flow for version 1.x. I think that is important to lock at it to understand MidiLayer.