The juce AU wrapper assumes that the HandleMidiEvent callback will never be called during Render(). It seems to be true on most hosts, but I have been notified of one host that does indeed call HandleMidiEvent during Render. Since the midiEvents.clear() is done at the end of Render(), all events that have been received during render are discarded.
Btw another host that does not take any precaution at not calling HandleMidiEvent during Render() is the Apple AudioUnitHosting example project.
I’m not sure of the best fix for that. Probably using two MidiBuffer and swapping them at the beginning of Render() (with a mutex to protect them) ?
I don’t know if all hosts will enjoy having their midi callback being locked for the duration of the rendercallback, maybe that could lead to missing other events or jittering , don’t you think ?