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

南笙酒味 提交于 2019-12-03 07:54:36

问题


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, 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


回答1:


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).



来源:https://stackoverflow.com/questions/2548238/how-to-get-a-volume-measurement-of-iphone-recording-in-db-with-a-limit-of-at-le

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!