gpt4 book ai didi

iOS 音频单元混响流格式问题 -10868 kAudioUnitErr_FormatNotSupported

转载 作者:行者123 更新时间:2023-12-01 16:00:36 24 4
gpt4 key购买 nike

我正在使用音频单元编写一个简单的 iOS 应用程序。我想添加混响效果。所以该图看起来像 RemoteIO_Input -> Reverb -> RemoveIO_Output。但是在尝试为混响单元设置流格式时出现错误 - kAudioUnitErr_FormatNotSupported。该代码在不使用混响单元(图中的单个远程 IO)的情况下工作正常,因此其他配置似乎没问题,我没有提供他们的代码。

UPD:使用 iOS 6

所以问题:

  1. 允许的格式有限制吗?

  2. 我应该使用什么格式的参数?

  3. 应在 RemoteIO 输出元素的任何范围内设置格式?

感谢关注。

代码:说明:

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;

图形设置

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);

格式说明及设置

   // 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 或使用基于预先构建的标志集(kAudioFormatFlagsAudioUnitCanonicalkAudioFormatFlagsCanonical) .就像这样,而不是像这样组成你自己的格式:

audioFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;

你会这样做:

audioFormat.mFormatFlags = kAudioFormatFlagsAudioUnitCanonical;

一般来说,如果您只是将两个装置相互连接起来,它们就能自行解决问题。如果您需要提供自己的音频,则必须指定输入格式(并且它可能需要基于kAudioFormatFlagsAudioUnitCanonical,这是非交错的线性 PCM,每个样本都是在 SInt32 容器中表示为固定的 8.24 数字。

如果您需要更大的灵 active ,您可以在混响单元之前放置一个 AUConverter 音频单元,因为 AUConverter 将能够处理更多的输入格式(例如适当的浮点样本)。请注意,这伴随着增加处理的警告,因为 AUConverter 必须实时转换音频格式。

您可以在 Core Audio Essentials 上看到完整的 ASBD 示例Canonical Audio Data Formats 标题下的页面。

Should set the format in any scope of RemoteIO output element?

如果您的混响单元直接连接到 RemoteIO 输出,这些单元应该能够自行解决。

关于iOS 音频单元混响流格式问题 -10868 kAudioUnitErr_FormatNotSupported,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13687092/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com