Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: how to convert getMaxAmplitude to db?

I have a piece of code that give me the getMaxAmplitude() of the audio from the mic. it works, but the value is surely strange. i need to convert it to decibel. how can i? i've found this formula: double db = 20 * Math.log10(recorder.getMaxAmplitude() / 2700.0); but i don't know if it's correct. thanks.

like image 972
Zak Avatar asked Nov 29 '12 15:11

Zak


1 Answers

The formula is correct, but the 2700.0 i don't know, because: Suppose this situation: We have a sound with 16 bit of depth. This means we will have 2^16 ("two to the 16th power") different amplitude values available to us, or 65,536 steps. Since the number of steps is divided between positive and negative values (our crests and troughs from before) this means it is divided into 32,767 positive (plus zero) and 32,768 negative values. Then:

db = 20 * log10(peaks/ 32767);

The "2700.0" rappresents the max amplitude value of the signals, but i don't know at wich bit depth. Regards.

like image 187
Antonio Avatar answered Sep 27 '22 19:09

Antonio