Search code examples
androidandroid-mediarecorder

MediaRecorder getMaxAmplitude return 9000 as the max value on my phone although shouting into the microphone


I understand that the getMaxAmplitude function in MediaRecorder should return values from 0 to 32762 but in my phone Sont Z Ultra Google Play Edition i keep getting 9000 as the max value although shouting into the mic. When testing in my friends Nexus 5 I'm getting 32762 so I know it's not related to my code.

I need to know what is the max amplitude that can be produced in every phone that runs my app, how can I do that?

Thank you.


Solution

  • Well after move testing I found out that changing this:

    this.mediaRecorder.setAudioSource(
           android.media.MediaRecorder.AudioSource.MIC
    );
    

    to this:

    this.mediaRecorder.setAudioSource(
           android.media.MediaRecorder.AudioSource.VOICE_COMMUNICATION
    );
    

    solves my problem. I get 32762 max amplitude in every device I tried it on.

    • Edit: This worked perfectly when using the AMR_NB AudioEncoder, when I switched to AAC it started to output 9000 as the max amplitude again. The solution was to change the audio source to VOICE_RECOGNITION