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.
The example is based on Apples SpeakHere app - on the AudioQueue callback function I'm using:
SInt16 *buffer = (SInt16*)inBuffer->mAudioData;
for (int i = 0; i < (inBuffer->mAudioDataByteSize)/sizeof(SInt16); i++)
{
printf("before modification %d\n", (int)*buffer);
buffer++;
}
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.
Audio Format Setup:
mRecordFormat.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked;
mRecordFormat.mBitsPerChannel = 16;
mRecordFormat.mBytesPerPacket = mRecordFormat.mBytesPerFrame = (mRecordFormat.mBitsPerChannel / 8) * mRecordFormat.mChannelsPerFrame;
mRecordFormat.mFramesPerPacket = 1;
Cheers,