开发者

How to read data from AudioQueueBufferRef->mAudioData

I'm trying to read an Audio data from AudioQueueBufferRef->mAudioData.

What I want to do is to print the buffer I read from the mic/file to the console.

I don't know in which format the audio data is represented. I tried to print it as long/int/float but nothing seems to give me the right data.

My code is very similar to SpeakHere sample provided by apple.

I'm trying to print the buffer like this: printf("%d ",((int*)inCompleteAQBuffer->mAudioData)[i]);

am I doing something wrong?? What is the right way to read the data from the mAudioData??

my Stream Description details are:

   开发者_如何学运维     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;


Apple's SpeakHere sample app has:

mRecordFormat.mBitsPerChannel = 16;

You have something different. A C short type is usually not the same size as a C int type on 32-bit RISC architectures, such as current iOS devices.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜