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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With