I am trying to fetch noise level of recorded audio in decibals. I am using following code but it is not giving the correct output
byte[] audioData = new byte[bufferSize];
recorder.read(audioData, 0, bufferSize);
ByteBuffer bb = ByteBuffer.wrap(audioData);
int sampleSize = bb.getInt();
now if I log sampleSize then it gives very huge value like 956318464
Can anybody tell how to get correct noise level in decibals.
First off- decibels is a ratio. You can't just get decibels, you need to compare the volume to a baseline measurement. So the real equation in terms of amplitude is
db= 10* log10(amplitude/baseline_amplitude);
If you're recording the audio now, to get the amplitude use MediaRecorder.getMaxAmplitude. For a baseline amplitude, measure the expected background noise.