views:

127

answers:

1

Hi all,

I'm working on an application that needs to perform recognition algorithms on raw PCM audio captured from the microphone. On all Android devices I've tested, the PCM data is usable (i.e., raw audio data.) This is not the case for the new Sprint EVO.

The Sprint EVO has AGC (Auto Gain Control) on the mic, which destroys the data such that our recognition algorithms no longer work.

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

Unfortunately, HTC has not yet posted the code used on this device. I expect that I may have to use JNI in order to bypass this for this specific device, and I'm willing to do this, but without access to the HTC source, I wouldn't know where to begin.

There is no way to reverse the effects of AGC, so I'm stuck trying to work around it.

More specific information:

I'm using AudioRecorder in order to get access to the raw PCM data. I've tried a few programs that use MediaRecorder to record AMR data and those recordings also exhibit the same AGC properties.

One thing I have yet to try, is to write my own routines to use MediaRecorder and use setAudioSource(AudioSource.VOICE_RECOGNITION). The only documentation I can find on this flag is from the Android reference, which simply states "Microphone audio source tuned for voice recognition if available, behaves like DEFAULT otherwise." This may be what I need, but would require the extra step of decoding the AMR data in order to get the PCM data (which I'll do if I have to.)

If anybody knows anything about this new "feature", any information would be greatly appreciated. Specifically, my life would be much better if I had the answers to any of the following questions:

  1. Is this new feature specific to HTC?
  2. When will HTC release their codebase for the EVO/Supersonic?
  3. Has anybody else run into this and found a way to work around the issue?
  4. Does AudioSource.VOICE_RECOGNITION actually prevent AGC?
  5. Does the existence of AudioSource.VOICE_RECOGNITION indicate that this is expected to be more common in future devices and this flag is a provision for bypassing it?

Any other clues, hints, tips would be greatly appreciated.

A: 

As it turns out, I found the solution while browsing the Android git depot:

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

For devices running OS 2.1 and above, 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'm targetting my app at 1.5 and above, and this VOICE_RECOGNITION flag isn't supported until API Level 7 (OS 2.1). However, since the EVO runs v2.1 and I'm relatively confident that this won't 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.

pnettle