How is AUv3 MIDI plug-in supposed to figure out the sample rate of the host?

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?

Accepted Reply

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

Replies

deleted my reply because I didn't read your question fully!

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

Hi. Thanks for posting this. We experienced the same issue here. We have some sync problems due to wrong sample rate initialized in our Audio Unit MIDI fx. I'm glad somebody figured out that's a bug in Logic. I hope the Logic team iOS will fix that soon.