How to get a volume measurement of iPhone recording in dB, with a limit of at least 120dB

Posted by Cyber on Stack Overflow See other posts from Stack Overflow or by Cyber
Published on 2010-03-30T19:55:53Z Indexed on 2010/03/31 7:13 UTC
Read the original article Hit count: 358

Filed under:
|
|
|
|

Hello,

I am trying to make a simple volume meter for the iPhone. I want the volume displayed in dB. When using this turorial, I am only getting measurements up to 78 dB. I've read that that is because the dBFS spectrum for 16 bit audio recordings is only 96 dB.

I tried modifying this piece of code in the init funcyion:

dataFormat.mSampleRate = 44100.0f;
dataFormat.mFormatID = kAudioFormatLinearPCM;
dataFormat.mFramesPerPacket = 1;
dataFormat.mChannelsPerFrame = 1;
dataFormat.mBytesPerFrame = 2;
dataFormat.mBytesPerPacket = 2;
dataFormat.mBitsPerChannel = 16;
dataFormat.mReserved = 0;

I changed the value of mBitsPerChannel, hoping to increase the bit value of the recording.

dataFormat.mBitsPerChannel = 32;

With that variable set to 32, the "mAveragePower" function returns only 0.

So, how can i measure more decibels? All my code is practically the same as in the tutorial i posted above.

Thanks in advance, Thomas

© Stack Overflow or respective owner

Related posts about iphone

Related posts about decibel