Adding/removing MidiMessages to MidiMessageSequence in the audio process loop


I had a quick search through old forum posts, and also had a look at the source code, and it seems that MidiMessageSequence uses a couple of things which should not be used there.

MidiMessageSequence::addEvent is calling “new”, and also perhaps the locks used in OwnedArray are not good for the audio thread either?

Previous threads suggest people have just kind of gotten away with using it anyway, but my plugin IS creating some very short crackles at the point where i randomise my sequence adding and removing up to 64 notes at the start of a bar.

If the length of my sequence is fixed at 64 steps, and all notes are guaranteed to be monophonic…then am i perhaps better off just writing my own sequence holder using normal arrays, of a simple MIdiBiuffer or something? The main reason i’m using the MidiMessageSequence class is because of its handy pairing of note on / note off elements, but i guess that’s not too hard to set up for myself either.

Any tips or ideas welcome… :slight_smile:


Yeah, you don’t want to write to that class in your audio processing callback. Reading from one is probably OK, but you’ll need to use a different thread to manipulate it.