iPhone SDK:AVAudioRecorder计量——如何将peakPowerForChannel从分贝更改为百分比?
iPhone SDK 中的 AVAudioRecorder 可用于获取通道的峰值功率和平均功率(以分贝为单位)。范围在0db到160db之间。用于将其转换为 0 - 10 之间的刻度或可用于音频电平表的类似值的计算是什么?
The AVAudioRecorder in the iPhone SDK can be used to get the peak and average power for a channel, in decibels. The range is between 0db to 160db. What is the calculation used to convert this into a scale between 0 - 10 or something similar that can be used for an audio level meter?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
范围为 -160 dB 至 0 dB。您可能希望以从 -90 dB 到 0 dB 的仪表显示它。将其显示为分贝实际上比线性音频电平更有用,因为分贝是对数刻度,这意味着它更接近于我们感知声音的大小。
也就是说,您可以使用它从分贝转换为线性:
线性 = pow (10, 分贝 / 20);
和相反的:
分贝 = log10 (线性) * 20;
code>上述分贝的范围是负无穷到零,线性的范围是 0.0 到 1.0。当线性值为0.0时,即-inf dB; 1.0 处的线性为 0 dB。
The range is from -160 dB to 0 dB. You probably want to display it in a meter that goes from -90 dB to 0 dB. Displaying it as decibels is actually more useful than as a linear audio level, because the decibels are a logarithmic scale, which means that it more closely approximates how loud we perceive a sound.
That said, you can use this to convert from decibels to linear:
linear = pow (10, decibels / 20);
and the reverse:
decibels = log10 (linear) * 20;
The range for the above decibels is negative infinity to zero, and for linear is 0.0 to 1.0. When the linear value is 0.0, that is -inf dB; linear at 1.0 is 0 dB.
Apple 还实现了 dB 到线性幅度转换类 MeterTable.cpp 和 MeterTable.h
在 SpeakHere 应用程序示例中查找它。
您可以使用其内联函数来“即时”计算值,
也可以
创建一个 MeterTable 实例来使用预先计算的查找表。这会将转换值存储在内存中,以便您的应用程序可以减少计算次数。
注意:如果您同时进行大量其他计算或者需要非常快速的处理,则可能需要查找表。
Apple also implemented a dB to linear amplitude conversion class MeterTable.cpp and MeterTable.h
Look for it in SpeakHere app example.
You can either use their inline function that calculates the value "on-the-fly"
OR
create a MeterTable instance to use pre-calculated lookup table. This stores conversion values in memory so your application can reduce number of calculations.
NOTE: lookup table is probably needed if you have a lot of other calculations going on at the same time or you need VERY fast processing.