Android: how to convert getMaxAmplitude to db?

I have a piece of code that gives me getMaxAmplitude () audio from a microphone. it works, but the value is definitely strange. I need to convert it to decibel. How can I? I found this formula: double db = 20 * Math.log10 (recorder.getMaxAmplitude () / 2700.0); but I do not know if this is correct. thanks.

+4
source share
1 answer

The formula is correct, but I do not know 2700.0, because: Suppose this situation: We have a sound with a depth of 16 bits. This means that we will have available values โ€‹โ€‹of amplitude 2 ^ 16 ("from two to 16th power") or 65 536 steps. Since the number of steps is divided between positive and negative values โ€‹โ€‹(our crests and troughs from the previous one), this means that it is divided into 32,767 positive (plus zero) and 32,768 negative values. Then:

db = 20 * log10(peaks/ 32767); 

"2700.0" represents the maximum value of the amplitude of the signals, but I do not know with a bit depth. Best wishes.

0
source

All Articles