Midi generator creation

The midiMessageSequence is sorted acc to the timestamps of its midi events so it's unneccassary to iterate through the complete sequence for every processblock call.

You could save the current midiSequence position in a member variable like nextEventID that you initalize to 0 or to
nextEvent ID = midiMessageSequence.getNextIndexAtTime (timeInMidiYouWantToStartAt), prior to any processBlock call.

 

In the processblock the code then could look something like

processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
   int numSamples = buffer.getNumSamples();   
   double numSecondsInThisBlock = numSamples / yourSampleFrequence;
   double endTime = playTime + numSecondsInThisBlock;

   MidiMessageSequence::MidiEventHolder *m;

   for (; m = midiSequence.getEventPointer (nextEventID); nextEventID++)
   {
      double timeStamp = m->getTimeStamp();
      if (timeStamp => endTime)
        break;   //we're done for now. leave remaining midi events to process calls to come!

      if (timeStamp => playTime)
         midiMessages.addEvent(midiMessage, timeStamp - playTime); //this event is within our time slot. 
   }


   playTime = endTime;
}