I want to detect blowing into the mic on android. Google wasn't much help. Is it possible?
OK! I found this online, so it definitely seems possible. It looks like you can call mediaRecorder.getMaxAmplitude().
Code from an app called NoiseAlert
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();
        mEMA = 0.0;
    }
}
public double getAmplitude() {
    if (mRecorder != null)
        return  (mRecorder.getMaxAmplitude()/2700.0);
    else
        return 0;
}
Here's the source
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With