As I understand it, a VST plugin receives a stream of audio and midi buffers from the host, and processBlock() in the AudioProcessor is used to make modifications to those buffers before they are passed back to the host. It is then up to the host to take care of routing the audio and midi messages (to external devices, to other plugins, to other tracks, etc.).
What I am having trouble grasping is how to inject a new midi message generated within the plugin itself into the stream. Let’s say I have a button in my editor, and that when it is clicked it creates a new midi note on message. Where can I put that message so that it is passed on to the host? Any suggestions will be appreciated!