Access to host MIDIOutputEventBlock in allocateRenderResources method of AUv3 app

I am using the AUv3 template that gets created by XCode to implement a MIDI AUv3 plugin of type "aumi". For the plugin to be able to send MIDI to a host it needs to be able to access the MIDIOutputEventBlock provided by the host. I have done some research and found that this is done by caching the MIDIOutputEventBlock in the allocateRenderResourcesAndReturnError method:

Code Block
_midiOut = self.MIDIOutputEventBlock;

and then using _midiOut in the internalRenderBlock method.

The first thing is that in the template that gets created isn't an allocateRenderResourcesAndReturnError method, there is only an allocateRenderResources method. When I apply that code in this method I get a compile error that basically says that this property is not found in the object of type xxxDSPKernelAdapter. I've seen in other examples (like Gene de Lisa's "Audio Units (AUv3) MIDI extension", a wonderful tutorial, by the way!) that the initial template from a couple years ago was very different from what I have and that MIDIOutputEventBlock is actually defined in the AUAudioUnit.h header file, but in this case self is also a different class.

I am very new at working with Objective-C, C++ and Swift in the same project, so I know my understanding of how this all works is minimal and very shallow. Any insight anybody could provide on this would be greatly appreciated.
My first entry on this question has a lot of errors and misconceptions but I can't edit it anymore.

First, the MIDIOutputEventBlock is a property of the Audio Unit plug-in. According to the header on this property: "The host can set this block and the plug-in can call it in its renderBlock to provide to the host the MIDI data associated with the current render cycle."

Second, in the example code that I referenced, the class that calls the allocateRenderResourcesAndReturnError and the internalRenderBlock methods is the actual AudioUnit class. In the template currently being generated by Xcode, these methods are part of the xxxDSPKernelAdapter so, of course, using self will generate a compile error.

Any insight anybody could provide on how to obtain and then cache the MIDIOutputEventBlock property, would be greatly appreciated.


Access to host MIDIOutputEventBlock in allocateRenderResources method of AUv3 app
 
 
Q