开发者

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

开发者 https://www.devze.com 2022-12-25 07:44 出处:网络
I am trying to make a simple volume meter for the iPhone. I want the volume to be displayed in dB. When using this turorial, I am only getting measurements up to 78 dB. I\'ve read that that is because

I am trying to make a simple volume meter for the iPhone. I want the volume to be 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 function:

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, hop开发者_如何学Cing 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


16 bit audio only has a dynamic range of 96 dB, but I suspect you may be getting confused between dB, which is a relative measurement, and dB SPL, which is an absolute measurement of sound pressure level. To measure dB SPL though you will need to calibrate your microphone and audio hardware with some kind of reference. Once you have your input calibrated then it may well be that your 96 dB of dynamic range translates to an absolute range of, say, 44 dB SPL to 140 dB SPL.

See also my answer to a previous similar question on SO: How can I calculate audio dB level?

Note: definition of dB SPL is sound pressure level relative to 20 µPa (rms).

0

精彩评论

暂无评论...
验证码 换一张
取 消