Using processblock vs handleincomingmidimessage

I’ve been reading through all the tutorials, and one thing that is not particularly clear to me is when you should use a midicallback for incoming messages, vs handling them via the processblock. Is anyone able to clear that up for me?
I am currently trying to build a simple MIDI editor for one of my synthesizers.
The only thing I’ve been able to work out is that sometimes ( particularly if running through the audiopluginhost), processblock will capture incoming midi messages even if the editor is closed - whereas it seems that the midicallback won’t. That could be entirely due to my implementation being wrong though!
It’s certainly a trial by fire learning this stuff. I wasted a day trying to figure out why I couldn’t pass messages to the host output, only to discover that the AU format doesn’t support it! As a result I’m now explicitly picking the output within the plugin from a dropdown, which is kind of a pain.

The difference is, processBlock you get the midi messages from the host, and they are timestamped!
While handleIncomingMidiMessage is raw from the midi device, and asynchronous.

If you write a host/standalone and you are not simply firing the events in realtime but want to record them, then you have to timestamp them yourself with any form of clock master.

Any event needs a reference clock, most of the time we use the audio as master clock, simply counting samples in relation from our timeline.

In a plugin you shouldn’t use the midi device directly for said synchronicity reasons.


Brilliant, thank you. That makes a lot more sense now.