iOS5 中将 kAudioUnitSubType_Varispeed 添加到 AUGraph

发布于 2024-12-12 04:58:33 字数 2025 浏览 0 评论 0原文

我正在尝试将 kAudioUnitSubType 添加到 iOS 5 中的 AUGraph,但是当我添加它并调用 AUGraphInitialize 时,会返回错误代码 -10868 (kAudioUnitErr_FormatNotSupported)。

这是我的 AudioComponentDescription:

AudioComponentDescription varispeedDescription;
varispeedDescription.componentType = kAudioUnitType_FormatConverter;
varispeedDescription.componentSubType = kAudioUnitSubType_Varispeed;
varispeedDescription.componentManufacturer = kAudioUnitManufacturer_Apple;
varispeedDescription.componentFlags = 0;
varispeedDescription.componentFlagsMask = 0;

如果我在初始化图表之前打印图表的状态,我会得到以下信息:

AudioUnitGraph 0x918000:
    Member Nodes:
    node 1: 'auou' 'rioc' 'appl', instance 0x16dba0 O  
    node 2: 'aumx' 'mcmx' 'appl', instance 0x1926f0 O  
    node 3: 'aufc' 'vari' 'appl', instance 0x193b00 O  
    Connections:
    node   2 bus   0 => node   3 bus   0  [ 2 ch,  44100 Hz, 'lpcm' (0x00000C2C)   8.24-bit little-endian signed integer, deinterleaved]
    node   3 bus   0 => node   1 bus   0  [ 2 ch,      0 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
    Input Callbacks:
    {0x39a5, 0x172e24} => node   2 bus   0  [2 ch, 44100 Hz]
    {0x39a5, 0x172e24} => node   2 bus   1  [2 ch, 44100 Hz]
  CurrentState:
    mLastUpdateError=0, eventsToProcess=F, isRunning=F

正如您所看到的,从 Varispeed 单元到远程 IO 单元的连接显示了一种非常奇怪的格式。更奇怪的是,如果我在模拟器上运行它而不是在我的开发设备上运行,则显示的格式是 16 位小端整数,去交错。如果我尝试在 Varispeed 单元的输入或输出范围上设置流格式,我会得到相同的错误代码 -10868。

我设置为输入范围上每个多通道混音器总线上的流格式的 asbd 如下:

stereoFormat.mSampleRate = sampleRate;
stereoFormat.mFormatID = kAudioFormatLinearPCM;
stereoFormat.mFormatFlags = kAudioFormatFlagsCanonical;
stereoFormat.mFramesPerPacket = 1;
stereoFormat.mChannelsPerFrame = 2;
stereoFormat.mBitsPerChannel = 16;
stereoFormat.mBytesPerPacket = 4;
stereoFormat.mBytesPerFrame = 4;

我没有使用音频单元的规范格式的原因是因为我正在从 AVAssetReader 读取样本,而我无法将其配置为输出8.24 有符号整数样本。

如果我从图中取出 Varispeed 单元并将多通道混音器单元连接到远程 IO 单元的输入,则图会初始化并正常运行。知道我做错了什么吗?

I am trying to add a kAudioUnitSubType to an AUGraph in iOS 5 but when I add it and call AUGraphInitialize an error code -10868 is returned (kAudioUnitErr_FormatNotSupported).

Here is my AudioComponentDescription:

AudioComponentDescription varispeedDescription;
varispeedDescription.componentType = kAudioUnitType_FormatConverter;
varispeedDescription.componentSubType = kAudioUnitSubType_Varispeed;
varispeedDescription.componentManufacturer = kAudioUnitManufacturer_Apple;
varispeedDescription.componentFlags = 0;
varispeedDescription.componentFlagsMask = 0;

If I print the state of the graph right before I initialise the graph I get the following:

AudioUnitGraph 0x918000:
    Member Nodes:
    node 1: 'auou' 'rioc' 'appl', instance 0x16dba0 O  
    node 2: 'aumx' 'mcmx' 'appl', instance 0x1926f0 O  
    node 3: 'aufc' 'vari' 'appl', instance 0x193b00 O  
    Connections:
    node   2 bus   0 => node   3 bus   0  [ 2 ch,  44100 Hz, 'lpcm' (0x00000C2C)   8.24-bit little-endian signed integer, deinterleaved]
    node   3 bus   0 => node   1 bus   0  [ 2 ch,      0 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
    Input Callbacks:
    {0x39a5, 0x172e24} => node   2 bus   0  [2 ch, 44100 Hz]
    {0x39a5, 0x172e24} => node   2 bus   1  [2 ch, 44100 Hz]
  CurrentState:
    mLastUpdateError=0, eventsToProcess=F, isRunning=F

As you can see the connection from the Varispeed unit to the Remote IO unit shows a very strange format. What is even more odd is that if I run this on the simulator as opposed to on my development device the format that shows is 16-bit little endian integer, deinterleaved. If I try to set the stream format on the input or output scopes of the Varispeed unit I get the same error code -10868.

The asbd that I am setting as the stream format on each Multichannel mixer bus on the input scope is as follows:

stereoFormat.mSampleRate = sampleRate;
stereoFormat.mFormatID = kAudioFormatLinearPCM;
stereoFormat.mFormatFlags = kAudioFormatFlagsCanonical;
stereoFormat.mFramesPerPacket = 1;
stereoFormat.mChannelsPerFrame = 2;
stereoFormat.mBitsPerChannel = 16;
stereoFormat.mBytesPerPacket = 4;
stereoFormat.mBytesPerFrame = 4;

The reason I am not using the canonical format for audio units is because I am reading samples from an AVAssetReader which I cannot configure to output 8.24 Signed Integer samples.

If I take out the Varispeed unit from the graph and connect the Multichannel Mixer unit to the input of the Remote IO unit the graph initialises and plays fine. Any idea what I'm doing wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

墨落成白 2024-12-19 04:58:33

您的 io 单元要求 32 位浮点数并从变速单元接收 8.24,因此出现格式错误。

您可以在 varispeed 的输出上设置流格式以匹配 io 单元的输入格式,如下所示:

AudioStreamBasicDescription asbd;
UInt32 asbdSize = sizeof (asbd);
memset (&asbd, 0, sizeof (asbd));

AudioUnitGetProperty(ioaudiounit , kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &asbd, &asbdSize);

AudioUnitSetProperty(varipseedaudiounit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 0, &asbd, sizeof(asbd));

your io unit is asking for 32bit float and recieving 8.24 from the varispeed unit, hence the format error.

you can set the stream format on the output of varispeed to match the input format of the io unit like this:

AudioStreamBasicDescription asbd;
UInt32 asbdSize = sizeof (asbd);
memset (&asbd, 0, sizeof (asbd));

AudioUnitGetProperty(ioaudiounit , kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &asbd, &asbdSize);

AudioUnitSetProperty(varipseedaudiounit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 0, &asbd, sizeof(asbd));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文