Converting from MidiFile to MidiBuffer

I am trying to build a plugin in which one functionality is that a user can import a MIDI file, process it, and then output the augmented MIDI data directly from the plugin in sync with the host DAW.

I am attempting to do this with the following flow of information (please correct me if this ‘meta’ structure needs to be changed):

  • Select the file with FileComponent
  • Load the file into a FileInputStream
  • Convert this stream into a MidiMessageSequence
  • Load the stream into a MidiBuffer and send to host

My confusion lies in between the last two points. How do I get a MidiMessageSequence into a MidiBuffer? Should the buffer contain the entire sequence of events, or just the number of samples as the buffer size?

For now I intend to keep the playback controls very basic, i.e. it can start reading the (augmented) buffer as soon as the playhead has hit a new bar, and play it until the end of the file.

Many thanks in advance for any guidance!