title: iPhone AudioQueue - Reading incoming audio data to determine BPM
body: <p>I'm trying to determine Beats Per Minute (BPM) from the microphone using sound energy, I think I've figured out the part determining BPM but having a little trouble obtaining the RAW data. </p>
  
  <p>The example is based on Apples SpeakHere app - on the AudioQueue callback function I'm using: </p>
  
  <pre><code>SInt16 *buffer = (SInt16*)inBuffer-&gt;mAudioData;   
  for (int i = 0; i &lt; (inBuffer-&gt;mAudioDataByteSize)/sizeof(SInt16); i++)
  {      
    printf("before modification %d\n", (int)*buffer); 
    buffer++;
  }  
  </code></pre>
  
  <p>But I'm getting some interesting values - any chance someone can point me in the right direction of where I'm going wrong and let me know what the range I should be getting back. </p>
  
  <p>Audio Format Setup: </p>
  
  <pre><code>mRecordFormat.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked;
  mRecordFormat.mBitsPerChannel = 16;
  mRecordFormat.mBytesPerPacket = mRecordFormat.mBytesPerFrame = (mRecordFormat.mBitsPerChannel / 8) * mRecordFormat.mChannelsPerFrame;
  mRecordFormat.mFramesPerPacket = 1;
  </code></pre>
  
  <p>Cheers, </p>