Rotem
Rotem

Reputation: 2356

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.

Upvotes: 0

Views: 1516

Answers (1)

Rotem
Rotem

Reputation: 2356

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

Upvotes: 1

Related Questions