ios - 使用 NOVOCAINE 计算 dB
<p><p>我想使用 <a href="https://github.com/alexbw/novocaine" rel="noreferrer noopener nofollow">NOVOCAINE</a> 计算 dB所以我的问题是我可以通过计算 RMS 来测量分贝吗?实际上我想要 iphone 的麦克风作为输入并监控周围的噪音。
我无法破解它。请帮忙。</p>
<p>请举个例子</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>基本上,这是 dB 满量程背后的数学:</p>
<p> <img src="/image/EXX6R.png" alt="Math behind dB fullscale"/> </p>
<p>其中 <code>b</code> 是位深度,在 iOS <code>b = 16</code> 上。 <a href="http://en.wikipedia.org/wiki/DBFS" rel="noreferrer noopener nofollow">More on Wikipedia</a> . </p>
<p>这可以通过如下方式实现:</p>
<pre><code>const float min = 20.0f*log10f(powf(2, 15)); // the "most silent" sample
Novocaine *audioManager = ;
[audioManager setInputBlock:^(float *newAudio, UInt32 numSamples, UInt32 numChannels)
{
float f = 0.0f;
for (int i = 0; i<numSamples; i++)
{
f += fabsf(newAudio); // we are only interested in non-imaginary values
}
f /= numSamples; // kind of a poor averaging...
float value_dB = 20.0f*log10f(f) - min; // dB in full scale
NSLog(@"%f dB for %f", value_dB, f); // or do whatever you want to do...
}];
;
</code></pre>
<p>但您应该考虑一下采样频率并记住这是 dB 满量程,而不是 <a href="http://en.wikipedia.org/wiki/Sound_pressure#Sound_pressure_level" rel="noreferrer noopener nofollow">dB SPL</a>或 <a href="http://en.wikipedia.org/wiki/Sound_intensity" rel="noreferrer noopener nofollow">dB SIL</a> . </p></p>
<p style="font-size: 20px;">关于ios - 使用 NOVOCAINE 计算 dB,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/27941808/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/27941808/
</a>
</p>
页:
[1]