For an AUv3 plug-in of type kAudioUnitType_MIDIProcessor how is the plug-in supposed to figure out the sample rate of the host? I think this might be an API limitation. For instruments and effects, we can read the AUAudioUnit's output bus format and check the sample rate. But MIDI FX plug-ins have no audio I/O. And even if I set them, Logic Pro, for example, doesn't update the AU if I change the sample rate in Logic.
Looking at AVAudioSession.sharedInstance.sampleRate
doesn't work either, because the host can have a different sample rate from the hardware.
Is there a solution to this that I'm not aware of?
I got a reply from Apple via DTS confirming it's a bug in Logic. To get the host sample rate from for a MIDI plug-in you are supposed to provide an output bus and then read the sample rate through the format
property after allocateRenderResourcesAndReturnError
called. And Logic doesn't seem to update the format property. If anyone wants to submit a duplicate the bug ID is FB12042397.
I've also started a Github project to demonstrate bugs or challenges I come across with AUv3s. https://github.com/Nikolozi/AudioUnitV3Experiments/tree/auv3_midi_sample_rate