Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AVAudioRecorder: peak and average power

What is the difference between peakPowerForChannel and averagePowerForChannel methods of AVAudioRecorder?

And why is the value returned is negative? Isn't it supposed to be 0 for no sound and go up when the amplitude of sound rises? How can I convert to a more "readable" format?

Thanks.

like image 476
Ilya Suzdalnitski Avatar asked Oct 26 '25 09:10

Ilya Suzdalnitski


1 Answers

Peak power means taking the maximum value of all the absolute values of all the samples. It's useful for preventing clipping of the audio.

Average power is the RMS (root-mean-square) of the samples. This is useful to determine how loud the audio sounds to human ears.

The value is negative because it is expressed in decibels, where 0 dB is equal to the maximum value of the audio system. It's a log10 scale, and the formula for conversion is:

db = 10 * log10 (level);

where db is decibels and level is the scalar value ranging from 0.0 to 1.0. So when the level is 0.0 (silent), the result is negative infinity.

If you want a "readable" format, you can use a level meter (UIProgressView or your own) where the max is 0.0 and the min is -60.0 (you can adjust depending on the noise floor). Once you're used to decibels, they make more sense than linear levels.

like image 191
lucius Avatar answered Oct 29 '25 09:10

lucius



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!