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
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With