android: Detect sound level
Use
mRecorder.getMaxAmplitude();
For the analysis of sound without saving all you need is use
mRecorder.setOutputFile("/dev/null");
Here´s an example, I hope this helps
public class SoundMeter {
private MediaRecorder mRecorder = null;
public void start() {
if (mRecorder == null) {
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mRecorder.setOutputFile("/dev/null");
mRecorder.prepare();
mRecorder.start();
}
}
public void stop() {
if (mRecorder != null) {
mRecorder.stop();
mRecorder.release();
mRecorder = null;
}
}
public double getAmplitude() {
if (mRecorder != null)
return mRecorder.getMaxAmplitude();
else
return 0;
}
}
ANDROID - Measuring the level of sound a user made and displaying it
Probably you can take a view on the stackoverflow post here.
Also a similar kind of project is available in code.google.com
Decibel Sound Meter for Android
Taken from Android Media Player Decibel Reading
For native android/java based decibel calculation for a MediaRecorder:
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mRecorder.setOutputFile("/dev/null");
mRecorder.prepare();
mRecorder.start();
public double getAmplitude() {
if (mRecorder != null)
return (mRecorder.getMaxAmplitude());
else
return 0;
}
To calculate Db value :
powerDb = 20 * log10(getAmplitude() / referenceAmp);
Reference: http://en.wikipedia.org/wiki/Decibel#Field_quantities
Not sure if you could do this in HTML5 on android
Related Topics
Programmatically Connect to Paired Bluetooth Device
How to Round an Image with Glide Library
Android Room: Insert Relation Entities Using Room
How to Make a Actionbar Like Google Play That Fades in When Scrolling
Using Disklrucache in Android 4.0 Does Not Provide for Opencache Method
Android: What Are the Recommended Configurations for Proguard
Android: How to Check If a Particular Accessibilityservice Is Enabled
How to Check an Android Device Is Hdpi Screen or Mdpi Screen
Avoid Button Multiple Rapid Clicks
Fragment Transaction Animation: Slide in and Slide Out
How to Call a Function After Delay in Kotlin
How to Generate Buildconfigfield with String Type
Android: Animation Position Resets After Complete
How to Create Android Spinner Without Down Triangle on the Right Side of the Widget