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

StackOverflow https://stackoverflow.com/questions/22431000

  •  15-06-2023
  •  | 
  •  

Question

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.

Was it helpful?

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top