views:

545

answers:

1

Hi developers,

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.

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.

Has anyone a formula to convert it back to the linear values between 0.0f and 1.0f?

Thanks

Tom

A: 

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));

where power is the value you get from one of the various level meter methods or functions, such as AVAudioPlayer's averagePowerForChannel:

invalidname