Search code examples
androidaudio-recordingandroid-audiorecord

Minimum volume threshold using AudioRecord on Android


I am creating an app like Talking Tom. I am using AudioRecorder for recording. I only have the basic Android, no Sound Touch. The problem I am facing is that I need to record only audio that is above a certain volume.

The statement:

if (recorder.getState() == AudioRecord.STATE_INITIALIZED)
{
    return recorder;
} 

The recorder gets initialized for even low-level volumes and keeps on recording even when I stop speaking and a very low level sound is in background.


Solution

  • You could run your AudioRecord continuously and do a level check (RMS or whatever measurement you prefer) at relatively close intervals. Once the sound level exceeds your desired threshold, save the buffer data until it drops below the stop threshold for a given amount of time, otherwise throw the data away.