How to read samples from AudioBufferList?

If I open an audio file with advanced audio file services using the following client data format ...

AudioStreamBasicDescription audioFormat;
memset(&audioFormat, 0, sizeof(audioFormat));
audioFormat.mSampleRate = 44100.0;
audioFormat.mFormatID = kAudioFormatLinearPCM;
audioFormat.mFormatFlags = kAudioFormatFlagIsBigEndian | 
                           kAudioFormatFlagIsSignedInteger | 
                           kAudioFormatFlagIsPacked;
audioFormat.mBytesPerPacket = 4;
audioFormat.mFramesPerPacket = 1;
audioFormat.mChannelsPerFrame = 2;
audioFormat.mBytesPerFrame = 4;
audioFormat.mBitsPerChannel = 16;

And configure AudioBufferList like that ...

AudioBufferList bufferList;
bufferList.mNumberBuffers = 1;
bufferList.mBuffers[0].mDataByteSize = bufferSize;
bufferList.mBuffers[0].mNumberChannels = audioFormat.mChannelsPerFrame;
bufferList.mBuffers[0].mData = buffer; //malloc(sizeof(UInt8) * 1024 * audioFormat.mBytesPerPacket)

What data is the data located in mData? If I repeat the data this way

for (int i = 0; i < frameCount; i++) {
        UInt8 somePieceOfAudioData = buffer[i];
}

what pieceOfAudioData is.

Is this a sample or a frame (left and right channels together)? If this is a sample, then for which channel is this a sample? If, for example, this is a sample from the right channel, will the buffer [i + 1] be a sample for the left channel?

Any ideas, links? Thank!

+5
source share
2 answers

, , kAudioFormatFlagIsNonInterleaved. , Core Audio . CoreAudioTypes.h :

, ASBD, , - AudioBuffer, AudioBufferList.

, ASBD kAudioFormatFlagIsNonInterleaved, AudioBufferList . , ASBD AudioBuffers, , AudioBuffer () . ASBD mChannelsPerFrame AudioBuffers, AudioBufferList - . AudioUnit ( AudioConverter) - AudioHardware .

, .

+9

, 16- : Left Right. ( , , , . .)

, Xcode. , " " " " , . ( , Xcode.. , .)

"Learning Core Audio: Mac iOS" , . "Rough Cut" Safari Books Online:

http://my.safaribooksonline.com/book/audio/9780321636973

+1

All Articles