如何获得 iPhone 录音的音量测量值(以 dB 为单位),限制至少为 120dB

发布于 2024-08-27 03:24:25 字数 725 浏览 5 评论 0原文

我正在尝试为 iPhone 制作一个简单的音量计。我希望音量以 dB 为单位显示。使用此图时,我只能获得高达 78 dB 的测量结果。我读到这是因为 16 位音频录音的 dBFS 频谱仅为 96 dB。

我尝试修改init函数中的这段代码:

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;

我改变了mBitsPerChannel的值,希望能够增加录音的bit值。

dataFormat.mBitsPerChannel = 32;

当该变量设置为 32 时,“mAveragePower”函数仅返回 0。

那么,如何测量更多分贝?我的所有代码实际上与我上面发布的教程中的代码相同。

提前致谢, 托马斯

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风启觞 2024-09-03 03:24:25

16 位音频的动态范围仅为 96 dB,但我怀疑您可能会对 dB 感到困惑,这是 相对测量,以及dB SPL,这是声压级绝对测量。要测量 dB SPL,您需要使用某种参考来校准麦克风和音频硬件。一旦您校准了输入,那么您的 96 dB 动态范围很可能会转化为 44 dB SPL 至 140 dB 等绝对范围SPL。

另请参阅我对之前类似问题的回答:如何计算音频 dB注意

:dB SPL 的定义是相对于 20 µPa (rms) 的声压级。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文