Is there an example of taking a MidiMessageSequence and playing it into the MidiBuffer of the AudioProcessor::processBlock?
I haven’t done it myself, but I would start looking into the arpeggiator example.
IIRC the selecting MidiMessages from a MidiMessageSequence into smaller MidiBuffers you will have to implement yourself. Usually MidiMessageSequences are more likely to be handled by the host though.
Yeah, I personally understand how to add midi messages to the MidiBuffer (and how to make the messages play at the right time). I’m more confused about how to get the messages from the MidiMessageSequence and ensure the notes play at the right time.
I don’t understand how to extract the messages at the right time to be played in the process block, without it being extremely expensive. From what I can tell just by looking at the API, the way to iterate over the midi messages in regards to time would be first calling .sort() then iterate between .begin() and .end(). To play the messages, the messages would be passed into the MidiBuffer when getTimeStamp() is greater than a time variable that’s updated like in the arpeggiator example.
If one has a huge MidiMessageSequence, iterating over the entirety of the sequence every process block seems really expensive. Is there a better way to approach this?
So after a decent amount of research I found this post about playing a MIDI file in JUCE. MIDI files are converted to multiple MidiMessageSequences (for each track) in JUCE, and the link plays the sequence in the processor block. It is essentially a tutorial on how to play MidiMessageSequences, and therefore a MidiMessageSequence example. Playing a MIDI file (revisited)