Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
888 views
in Technique[技术] by (71.8m points)

core audio - iPhone SDK: AVAudioRecorder metering -- how to change peakPowerForChannel from decibel into percentage?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...