【问题标题】:How to read data from AudioQueueBufferRef->mAudioData如何从 AudioQueueBufferRef->mAudioData 读取数据
【发布时间】:2011-04-28 22:54:18
【问题描述】:

我正在尝试从 AudioQueueBufferRef->mAudioData 读取音频数据。

我想做的是将我从麦克风/文件读取的缓冲区打印到控制台。

我不知道音频数据以哪种格式表示。 我尝试将其打印为 long/int/float,但似乎没有任何东西可以给我正确的数据。

我的代码与苹果提供的SpeakHere 示例非常相似。

我正在尝试像这样打印缓冲区: printf("%d",((int*)inCompleteAQBuffer->mAudioData)[i]);

我做错了吗? 从 mAudioData 读取数据的正确方法是什么?

我的流描述详细信息是:

        streamDescription.mFormatID = kAudioFormatLinearPCM;

    // if we want pcm, default to signed 16-bit little-endian
    streamDescription.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked;
    streamDescription.mBitsPerChannel = 8 * sizeof (int);
    streamDescription.mBytesPerPacket = streamDescription.mBytesPerFrame = (streamDescription.mBitsPerChannel / 8) * streamDescription.mChannelsPerFrame;
    streamDescription.mFramesPerPacket = 1;

【问题讨论】:

    标签: iphone core-audio


    【解决方案1】:

    Apple 的 SpeakHere 示例应用具有:

    mRecordFormat.mBitsPerChannel = 16;
    

    你有不同的东西。在 32 位 RISC 架构(例如当前的 iOS 设备)上,C 短类型通常与 C int 类型的大小不同。

    【讨论】:

      猜你喜欢
      • 2013-12-11
      • 2012-03-09
      • 2011-01-26
      • 2019-02-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多