iPhone - AVAudioPlayer - 将分贝级别转换为百分比 [英] iPhone - AVAudioPlayer - convert decibel level into percent
问题描述
我想更新使用AudioQueue播放音频文件的现有iPhone应用程序。级别(peakPowerForChannel,averagePowerForChannel)是0.0f到1.0f的线性形式。
I like to update an existing iPhone application which is using AudioQueue for playing audio files. The levels (peakPowerForChannel, averagePowerForChannel) were linear form 0.0f to 1.0f.
现在我喜欢使用更简单的AVAudioPlayer类,工作正常,唯一的问题是现在以分贝为单位的水平,而不是从-120.0f到0.0f的线性。
Now I like to use the simpler class AVAudioPlayer which works fine, the only issue is that the levels which are now in decibel, not linear from -120.0f to 0.0f.
有没有人将公式转换回0.0f和1.0f之间的线性值?
Has anyone a formula to convert it back to the linear values between 0.0f and 1.0f?
谢谢
Tom
推荐答案
几个Apple示例使用以下公式将分贝转换为线性范围(从0.0到1.0):
Several Apple examples use the following formula to convert the decibels into a linear range (from 0.0 to 1.0):
double percentage = pow (10, (0.05 * power));
其中 power
是你得到的价值各种电平表方法或功能之一,例如AVAudioPlayer的 averagePowerForChannel:
where power
is the value you get from one of the various level meter methods or functions, such as AVAudioPlayer's averagePowerForChannel:
这篇关于iPhone - AVAudioPlayer - 将分贝级别转换为百分比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!