• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

iphone - iOS LPCM 非交错音频输入,2 个 channel : not possible?

[复制链接]
菜鸟教程小白 发表于 2022-12-12 15:38:57 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

aurioTouch示例应用程序 RemoteIO 音频单元配置为 8.24 定点格式的 2 channel 非交错 LPCM。这是 iOS 平台上的首选格式,我假设这就是硬件 ADC 发出的内容。他们甚至对此发表了评论(source):

// set our required format - Canonical AU format: LPCM non-interleaved 8.24 fixed point
outFormat.SetAUCanonical(2, false);

所以我希望当应用程序稍后收到一个音频缓冲区时,它的 mData 成员中会以某种顺序包含两个 channel 的数据。像这样的:

mData = [L1, L2, L3, L4, R1, R2, R3, R4];

其中 L 和 R 代表来自立体声麦克风左右声道的数据。只是似乎不可能,因为 SetAUCannonical() 没有设置足够的内存来保存附加 channel :

void    SetAUCanonical(UInt32 nChannels, bool interleaved)
{
    mFormatID = kAudioFormatLinearPCM;
#if CA_PREFER_FIXED_POINT
    mFormatFlags = kAudioFormatFlagsCanonical | (kAudioUnitSampleFractionBits << kLinearPCMFormatFlagsSampleFractionShift);
#else
    mFormatFlags = kAudioFormatFlagsCanonical;
#endif
    mChannelsPerFrame = nChannels;
    mFramesPerPacket = 1;
    mBitsPerChannel = 8 * sizeof(AudioUnitSampleType);
    if (interleaved)
        mBytesPerPacket = mBytesPerFrame = nChannels * sizeof(AudioUnitSampleType);
    else {
        mBytesPerPacket = mBytesPerFrame = sizeof(AudioUnitSampleType);
        mFormatFlags |= kAudioFormatFlagIsNonInterleaved;
    }
}

如果 'interleaved' 为 false,它不会将 'mBytesPerPacket' 和 mBytesPerFrame' 乘以 channel 数。帧中没有足够的位来存储额外的 channel 。

那么当示例代码要求 2 个 channel 时,它会不会有点误导?它是否应该只要求 1 个 channel ,因为无论如何它都会返回:

outFormat.SetAUCanonical(1, false);

我可以像这样“修复”SetAUCannonical 以使事情变得清晰吗?:

mChannelsPerFrame = nChannels;
if (!interleaved) {
    mChannelsPerFrame = 1
    mFormatFlags |= kAudioFormatFlagIsNonInterleaved;
}
mFramesPerPacket = 1;
mBitsPerChannel = 8 * sizeof(AudioUnitSampleType);
mBytesPerPacket = mBytesPerFrame = nChannels * sizeof(AudioUnitSampleType);     

或者还有什么其他原因会要求您提供 2 个 channel ?我什至不认为麦克风是立体声麦克风。



Best Answer-推荐答案


内置麦克风和耳机麦克风输入均为单声道。

相机连接套件可能允许在运行某些以前的操作系统版本的一些较新的 iOS 设备上从某些 USB 麦克风输入立体声音频,但我没有看到任何关于这与当前操作系统版本一起使用的报告。

另外,检查 2 channel (立体声)非交错格式是否可能将 2 个缓冲区返回到 RemoteIO 回调,而不是 1 个缓冲区中的连接数据。

关于iphone - iOS LPCM 非交错音频输入,2 个 channel : not possible?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4422672/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap