Android: how to convert getMaxAmplitude to db?
Asked Answered
C

1

7

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.

Chalkstone answered 29/11, 2012 at 15:28 Comment(1)
SOLVED: double db = 20 * Math.log(recorder.getMaxAmplitude() / 2700.0);Chalkstone
T
1

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.

Telegraphy answered 30/7, 2014 at 10:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.