1
votes

I am using MediaRecorder to try to create a sound meter which returns the Sound Pressure Level (what I believe most people mean when they refer to everyday volume in decibels).

Currently, I am using this implementation to get values in decibels:

return 20.0 * Math.log10(Math.abs(mMediaRecorder.getMaxAmplitude()) / 32768)

I'm not sure if this is correct. Sitting in a room with no noise other than a fan, it is returning values anywhere between -30 and -20. If I speak near the microphone, it jumps to values near -0.5 or so.

Reading many answers on this website, it seems that is is difficult and largely unreliable to measure SPL without calibrated devices. However, I don't need highly accurate results, only results applicable to everyday curiousity and non-extreme situations.

There are apps such as Sensor Box for Android, which seem to return decent results with no calibration needed to start. Using it in the same room, it is returning results between 40-60dB, and when I speak it jumps into the 80-90dB range.

How can I duplicate these results? Thank you!

1
You say you don't need accurate results, but how accurate? In what way would a meaningless number inform your curiosity? It seems that the results for your demo app are way off too. For example, see the low dBSPL values here: en.wikipedia.org/wiki/Sound_pressure#Examples_of_sound_pressure The thing to note with your sample app is that they only claim information about "intensity changes", and for that, calibration doesn't matter too much, and my guess is they only report "dB" not "dBSPL".tom10
I suppose what I mean by not needing highly accurate results is that I would like the app to perform similar to any simple sound meter someone would pick up at a store for $10-15. Nothing high-end and highly precise, but not random either.OnThisDayFiftyYearsAgo
BTW, on the Sensor box returning "decent" results- a quick look up says 80-90 is way high for speech. 80-90 is hearing damage range over the long term, its equivalent to a heavily trafficed road. Remember being off by 1 dB is logarithmic, so it doesn't mean slightly more, it means an order of magnitude more noise. en.wikipedia.org/wiki/Sound_pressure#Examples_of_sound_pressureGabe Sechan
Ideally as accurate as possible using only the phone's standard microphone. I just mean not as accurate as an expensive sound meter an audio professional might use.OnThisDayFiftyYearsAgo
I think you're both right on the inaccuracy of the Sensor Box app, because it consistently returns a measure of ~80-90 dB when I speak near the phone in a regular voice.OnThisDayFiftyYearsAgo

1 Answers

1
votes

Your first problem is that decibels isn't an exact measurement- its a signal to noise ratio. You need a base measurement and need to measure the ratio of the amplitude of your signal to that baseline noise. Amplitude alone is meaningless.

Your second problem- where did you get 32768 from? The formula should be 20.0 * Math.log10(Math.abs(signal/baseline)).