How to disable AGC on HTC EVO (supersonic)?

I am working on an application that should run recognition algorithms on raw PCM audio captured from a microphone. On all the Android devices I tested, PCM data can be used (i.e., the original audio data). This does not apply to the new Sprint EVO.

Sprint EVO has AGC (Auto Gain Control) on the microphone, which destroys data, so our recognition algorithms no longer work.

I believe this is a feature that HTC has added to the OS for this device (and possibly future devices). I tested our application on several other devices using the same OS version (2.1), and these other devices behave normally.

Unfortunately, HTC has not yet published the code used on this device. I expect that I may have to use JNI to get around this for this particular device, and I'm ready to do it, but without access to the HTC source, I don't know where to start.

It is not possible to change the effects of AGC, so I'm stuck trying to get around it.

More specific information:

I use AudioRecorder to access raw PCM data. I tried several programs that use MediaRecorder to record AMR data, and these records also demonstrate the same AGC properties.

One thing I still have to try is to write my own procedures to use MediaRecorder and use setAudioSource (AudioSource.VOICE_RECOGNITION). The only documentation I can find on this flag is the Android link, which simply says: "The microphone's sound source, configured to recognize voice, if available, behaves like DEFAULT otherwise." This may be what I need, but it will take an extra step to decode the AMR data to get the PCM data (which I will do if necessary).

If anyone knows anything about this new โ€œfeature,โ€ any information would be greatly appreciated. In particular, my life would be much better if I had answers to any of the following questions:

  • Is this a new feature for HTC?
  • When will HTC release its code base for EVO / Supersonic?
  • Has anyone else come across this and found a way around the problem?
  • Does AudioSource.VOICE_RECOGNITION really prevent AGC?
  • Does AudioSource.VOICE_RECOGNITION exist, which is expected to be more common in future devices, and is this flag a condition for circumventing it?

Any other hints, hints, hints are welcome.

+4
source share
2 answers

As it turned out, I found a solution while watching Android git depot:

AudioRecord ar = new AudioRecord(MediaRecorder.AudioSource.VOICE_RECOGNITION, ...); 

For devices running OS 2.1 and higher, this allows you to receive an audio stream that is not affected by AGC, and is still a high-quality 16-bit PCM data stream.

I am targeting my application at 1.5 and above, and this VOICE_RECOGNITION flag is not supported until API level 7 (OS 2.1). However, since EVO works v2.1, and I am relatively confident that this will not be a problem for any device prior to OS 2.1, a simple version check will do the trick to limit the solution to only those devices that need / support it.

+6
source

Unfortunately,

 AudioRecord ar = new AudioRecord(MediaRecorder.AudioSource.VOICE_RECOGNITION, ...); 

not a common solution. Some manufacturers use AGC, even if MediaRecorder.AudioSource.VOICE_RECOGNITION is selected. They simply ignore Google "Compatibility Determination". See How to avoid automatic gain control with AudioRecord?

0
source

Source: https://habr.com/ru/post/1312275/


All Articles