title: Determine Number of Frames in a Core Audio AudioBuffer
body: <p>I am trying to access the raw data for an audio file on the iPhone/iPad. I have the following code which is a basic start down the path I need. However I am stumped at what to do once I have an AudioBuffer.</p>
  
  <pre><code>AVAssetReader *assetReader = [AVAssetReader assetReaderWithAsset:urlAsset error:nil];
  AVAssetReaderTrackOutput *assetReaderOutput = [AVAssetReaderTrackOutput assetReaderTrackOutputWithTrack:[[urlAsset tracks] objectAtIndex:0] outputSettings:nil];
  [assetReader addOutput:assetReaderOutput];
  [assetReader startReading];
  
  CMSampleBufferRef ref;
  NSArray *outputs = assetReader.outputs;
  AVAssetReaderOutput *output = [outputs objectAtIndex:0];
  int y = 0;
  while (ref = [output copyNextSampleBuffer]) {
      AudioBufferList audioBufferList;
      CMBlockBufferRef blockBuffer;
      CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer(ref, NULL, &amp;audioBufferList, sizeof(audioBufferList), NULL, NULL, 0, &amp;blockBuffer);
      for (y=0; y&lt;audioBufferList.mNumberBuffers; y++) {
          AudioBuffer audioBuffer = audioBufferList.mBuffers[y];
          SInt16 *frames = audioBuffer.mData;
          for(int i = 0; i &lt; 24000; i++) { // This sometimes crashes
              Float32 currentFrame = frames[i] / 32768.0f;
          }
      }
  }
  </code></pre>
  
  <p>Essentially I don't know how to tell how many frames each buffer contains so I can't reliably extract the data from them. I am new to working with raw audio data so I'm open to any suggestions in how to best read the mData property of the AudioBuffer struct. I also haven't done much with void pointers in the past so help with that in this context would be great too!</p>