获取 Android 麦克风的分贝

发布于 2024-10-03 22:04:41 字数 145 浏览 5 评论 0原文

我已经搜索了一段时间了,但一直没能找到一种方法来实际从 Android 上的麦克风获取 SPL/db 值。

我发现讨论它的少数线程和文章将其视为显而易见的事情,任何人都应该能够做到这一点,并且更关心如何使他们的转换算法正确。

有谁知道该怎么做?

I have been searching for quite some time now, and I haven't been able to find a way to actually get an SPL/db value from a microphone on Android.

The few threads and articles that I have found that discussed it treated it like something so obvious that anyone should be able to do it, and were more concerned with getting their conversion algorithms correct.

Does anyone know how to do this?

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

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

发布评论

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

评论(3

梦情居士 2024-10-10 22:04:41

在开发其他相关应用程序并进行研究时,我发现了一些信息,这些信息对于任何正在研究此类内容的人来说都是有用的。

您会看到,Android 手机上的麦克风将返回 0 到 +- 32,400 之间的值。大多数情况下,超过 2,000 的任何声音都非常吵,例如音乐会、俱乐部或机械噪音。 “相对沉默”约为 30。但是,这些值的含义是相对的,并且会因手机而异。由于其中有麦克风,彼此相邻的多个设备将返回不同的值。这些值可能略有不同,或者很多

刚刚在我的办公室测试了几款不同的 Android 手机,我发现某些设备在相同情况下返回的值是其他设备的 10 倍。这就是为什么没有人刚刚说“是的,你可以获得分贝值,这里有一些示例代码:”,因为实际上并没有真正可靠(且简单)的方法来做到这一点。

如果您将其上传到一台设备上,您可能会得到 30 dB,但另一台设备会返回 300dB。显然,如果没有大规模的耳朵保护,任何人都不会处于 300 分贝的环境中。这些值必须被视为相对值;他们之间的关系如何。如果您想获得可以使用的值,“校准”,无论是动态的还是其他方式,都是必须的。必须有一个既定的基线,该基线不能来自您,必须与您的值进行比较。例如,如前所述,相对静音应该在 30 左右。

如果手机在相对静音环境中返回 456,则只需将您的 (30) 除以他们的 (456),您就得到了一个可用于调整静音的系数。电话返回的值,以便它们与您期望看到的内容相匹配,并且这些值可用于一定程度的可靠性。

这是我这几个月的发现,希望对大家有帮助。

While working on other related apps, and doing research, I have come across some information that would be useful to anyone who is looking into something such as this.

You see, the microphone on an Android phone will return a value between 0 and +- 32,400. For the most part, anything over 2,000 is really loud, such as a concert, club, or mechanical noise. "Relative Silence" is around 30. However, these values' meanings are relative, and will differ from phone to phone. Several devices sitting right next to each other will return different values, because of the microphones in them. The values can differ a little, or a lot.

Just testing several different android powered phones in my office, I have found that some devices would return values 10× that of other devices in the same situation. This is why there hasn't been anyone who has just said "Yeah, you can get the decibel value, here's some sample code:" because there is NOT really a reliable (and easy) way TO do it, realistically.

If you uploaded it on one device, you could get, say, 30 dB, but another would return 300dB. Clearly, no human would be in an evironment with 300 dB without massive ear protection. The values have to be taken as relative values; how they relate to each other. "Calibration", whether dynamic or otherwise, is a must if you want to get values that you can use. There has to be an established baseline, that cannot come from you, which has to be compared to a value from you. For example, relative silence, as stated before, should be around 30.

If the phone returns 456 in a relative silence environment, then simply divide yours (30) by theirs (456), and you have a factor that will serve as adjusting the values returned by the phone so that they match what you are expecting to see, and those values can be used for some degree of reliability.

This is just what I have found over the past few months, I hope it helps someone.

静若繁花 2024-10-10 22:04:41

您必须首先禁用任何自动电平控制。我假设您知道或者知道去哪里查找如何在不使用 ALC 的情况下从麦克风录制样本。

从那时起,它基本上都是关于校准和对数幅度的。本质上,您将乘以或卷积与频率相关的校准,然后在全部或部分频率范围内取 10 * 对数幅度。

然后,您必须进行一些校准测量,例如对受控、已知声压级的实验室源进行频率扫描,并记录所得的幅度与频率的关系(如果您缓慢扫描,则其本质上与幅度与时间的关系相同),否则您将用宽带伪脉冲(例如电火花、发令枪等)击中它,您还可以在辐射对称位置使用良好的实验室设备在整个频率上进行测量,或者作为最后的手段,您使用该器件的一些已知物理特性源来估计 SPL,并希望它在感兴趣的频率上足够平坦。

然后,您有两种选择如何应用校正。

一种选择是反转传递函数,计算时域脉冲响应,然后通过将其与输入信号进行卷积以应用频率平坦度校正,将其用作数字滤波器。然后,您可以取每单位时间结果的对数幅度来确定宽带声压级。

或者,您可以对输入数据进行 FFT 以生成频谱,并将其乘以频率响应的倒数,并获取任何感兴趣的 bin(和)的对数幅度。

不幸的是,没有什么理由可以假设设备之间的粗略一致性,即使是同一型号。

You would have to first disable any automatic level control. I assume you either know, or know where to look to find out how to record samples from the microphone without ALC.

From then on, its basically all about the calibration and log magnitude. Essentially you will multiply or convolve by a frequency-dependent calibration and then take 10 * the log magnitude over all or some of the frequency range.

Then you'd have to take some calibration measurements, for example frequency sweeping a lab source of controlled, known spl and recording the resulting amplitude vs frequency (which if you sweep slowly is essentially the same as amplitude vs. time) or you'd hit it with a wideband pseudo impulse (such as an electric spark, starter pistol, whatever) that you are also measuring across frequency with good lab equipment in a radiation-symmetric position, or as a last resort you use some known physical property of the source to estimate the SPL and just hope it's flat enough across frequencies of interest.

You then have two choices for how to apply the correction.

One option is to invert the transfer function, calculate the time domain impulse response, and then use that as a digital filter by convolving it with an input signal to apply a frequency-flatness-correction. You can then take the log magnitude of the result per unit time to determine wideband spl.

Or you can do an FFT on the input data to generate a frequency spectrum, and multiply that by the inverse of your frequency response, and take the log magnitude of whatever (sum of) bin(s) is interesting.

Unfortunately, there's little reason to assume more than crude consistency from device to device, even of the same model.

往昔成烟 2024-10-10 22:04:41

开源应用程序 NoiseTube 可以做到这一点,包括对设备特定校准的支持。源代码位于此处。如果您可以访问它,我强烈建议您阅读他们的文章参与式噪声映射有效!对参与式传感作为环境监测标准技术替代方案的评估可用付费)。

来源的一些亮点:

The open source app NoiseTube does this, including support for device specific calibration. Source code is available here. If you can access it I strongly recommend reading their article Participatory noise mapping works! An evaluation of participatory sensing as an alternative to standard techniques for environmental monitoring (available for pay).

Some highlights from the source:

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