Apple's Voice Processing Audio Unit ( kAudioUnitSubType_VoiceProcessingIO ) broken on iOS 5.1

倖福魔咒の 提交于 2019-11-29 05:02:11
robbie_c

TL;DR add kAudioFormatFlagsIsPacked to FORMAT_FLAGS

I discovered this via a bit of a convoluted route. None of this seems to be well documentated anywhere, but I came across this SO post talking about using the IO on a Mac. One of the things mentioned was using "FlagsCononical". I tried setting:

#define FORMAT_FLAGS kAudioFormatFlagsAudioUnitCanonical

which didn't work, and the call to AudioUnitInitialize failed with a return code of 29759. I couldn't find any documentation about what this meant, but when I tried:

#define FORMAT_FLAGS kAudioFormatFlagsCanonical

everything worked! Success!

The definition of kAudioFormatFlagsCanonical in CoreAudioTypes.h if you are building for an iPad (and therefore have CA_PREFER_FIXED_POINT defined as 1) is:

kAudioFormatFlagsCanonical = kAudioFormatFlagsIsSignedInteger
                           | kAudioFormatFlagsNativeEndian
                           | kAudioFormatFlagIsPacked;

After adding kAudioFormatFlagIsPacked to my original code it worked. I added kAudioFormatFlagsNativeEndian for good measure. I removed kAudioFormatFlagsIsNonInterleaved as it was unnecessary for single channel audio anyway. What I was left with is identical to kAudioFormatFlagsCanonical.

So my set-up, which worked on an iPad 2 (iOs 5.1) and an iPad 3 (iOS 6.0) was the following:

  • Sample rate of 48000
  • 1 channel
  • kAudioFormatFlagsCanonical
  • int16_t samples
  • Linear PCM

I'm still keen on documentation for this IO if anyone has any, and of course if this helped you don't forget to upvote :)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!