Randomizing the timing of MIDI notes

Hey everyone,

So I’m working on a plugin that humanizes MIDI tracks. Randomizing the velocities was easy enough, but randomizing the timing of the notes is proving more difficult, as they often need to extend beyond the scope of their current buffer. I’ve figured out how to move notes to a future MIDI Buffer (I transfer them to a secondary buffer and then continuously subtract the buffer size from it’s timestamp until it reaches the correct buffer). However, I’m struggling with what to do for notes that get randomized to occur BEFORE they are supposed to. I’m assuming I’d have to utilize some sort of “look ahead” feature so that I can move notes to a previous buffer before that buffer is outputted? Does anyone have any ideas on how to do this, or any example projects that deal with something similar? I hope this was clear enough, if I can clarify in any way please let me know!

I’m fairly new to JUCE, but I look forward to contributing to this forum where I can. Thanks for any help you can provide!

I would also like to design a plugin which would shift midi messages “backwards” in time. Of course this is not possible for live midi input. I have come across at least three posts whose crux is how best to impliment this functionality or if this is even possible - something like ARA for midi. Did you ever come up with a solution to this?