iOS Audio units reverb stream format issue -10868 kAudioUnitErr_FormatNotSupported
我正在用音频单元编写一个简单的iOS应用。我想添加混响效果。
因此该图看起来像RemoteIO_Input-> Reverb-> RemoveIO_Output。
但是尝试为混响单元-
该代码在不使用混响单元(图形中的单个远程IO)的情况下可以正常工作,因此其他配置似乎很好,我没有提供其代码。
UPD:使用iOS 6
所以问题:
允许的格式是否有限制?
我应该使用哪种格式的参数?
是否应在RemoteIO输出元素的任何范围内设置格式?
感谢您的关注。
代码:
说明:
1 2 3 4 5 6 7 8 9 10 11 | desc.componentType = kAudioUnitType_Output; desc.componentSubType = kAudioUnitSubType_RemoteIO; desc.componentFlags = 0; desc.componentFlagsMask = 0; desc.componentManufacturer = kAudioUnitManufacturer_Apple; descRev.componentType = kAudioUnitType_Effect; descRev.componentSubType = kAudioUnitSubType_Reverb2; descRev.componentFlags = 0; descRev.componentFlagsMask = 0; descRev.componentManufacturer = kAudioUnitManufacturer_Apple; |
图形设置
1 2 3 4 5 6 7 8 | NewAUGraph(&graph); AUNode ioNode; AUNode rNode; AUGraphAddNode(graph, &desc, &ioNode); AUGraphAddNode(graph, &descRev, &rNode); AUGraphOpen(graph); AUGraphConnectNodeInput(graph, ioNode, 1, rNode, 0); AUGraphConnectNodeInput(graph, rNode, 0, ioNode, 0); |
格式说明和设置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | // Describe format audioFormat.mSampleRate = rate;//44100.00; audioFormat.mFormatID = kAudioFormatLinearPCM; audioFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked; audioFormat.mFramesPerPacket = 1; audioFormat.mChannelsPerFrame = 1; audioFormat.mBitsPerChannel = 16; audioFormat.mBytesPerPacket = 2; audioFormat.mBytesPerFrame = 2; OSStatus err = AudioUnitSetProperty(unit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, kInputBus, &audioFormat, sizeof(audioFormat)); if (noErr != err) { [self showStatus:err]; } err = AudioUnitSetProperty(unitRev, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &audioFormat, sizeof(audioFormat)); if (noErr != err) { [self showStatus:err]; } |
Are there restrictions for the allowed formats?
是的,它们通常非常严格。
What format params should I use?
使用单元的默认ASBD或使用基于预构建的标志集(
1 | audioFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked; |
您将执行以下操作:
1 | audioFormat.mFormatFlags = kAudioFormatFlagsAudioUnitCanonical; |
通常来说,如果您仅将两个单元相互连接,它们便可以自行解决。如果需要提供自己的音频,则必须指定输入格式(并且可能需要基于
如果需要更大的灵活性,可以将
您可以在Core Audio Essentials页面上的Canonical Audio Data Formats标题下看到完整的ASBD示例。
Should set the format in any scope of RemoteIO output element?
如果您的混响单元直接连接到RemoteIO输出,则这些单元应能够自行对其进行分类。