Good day! I need to graphically (in principle, any method fits) determine and show the sensitivity of the microphone, more precisely decibella, which go when recording to its input ... at least just .. there is a voice, there is no voice .. the levels .. I cannot find and whether there is such a functional. I use AudioRecord.

1 answer 1

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; } } 

When you need to get a level, call SoundMeter.getAmplitude();
You can display the value, for example, in the ProgressBar .
If you need to get this value all the time, you can do it in the buskonechny cycle, first having transferred the code to the background stream

  • @Fox, if it helped - mark the answer as correct, thanks to the bread you will not smear ... - Vladyslav Matviienko