Configuring Pre-Processing Effects

The Android platform provides audio effects on supported devices in the audiofx package, which is available for developers to access. For example, the Nexus 10 supports the following pre-processing effects:

Pairing with AudioSources

Pre-processing effects are paired with the use case mode in which the pre-processing is requested. In Android app development, a use case is referred to as an AudioSource; and app developers request to use the AudioSource abstraction instead of the actual audio hardware device. The Android Audio Policy Manager maps an AudioSource to a given capture path configuration (device, gain, pre processing, etc.) according to product-specific rules. The following sources are exposed to developers:

  • android.media.MediaRecorder.AudioSource.CAMCORDER
  • android.media.MediaRecorder.AudioSource.VOICE_COMMUNICATION
  • android.media.MediaRecorder.AudioSource.VOICE_CALL
  • android.media.MediaRecorder.AudioSource.VOICE_DOWNLINK
  • android.media.MediaRecorder.AudioSource.VOICE_UPLINK
  • android.media.MediaRecorder.AudioSource.VOICE_RECOGNITION
  • android.media.MediaRecorder.AudioSource.MIC
  • android.media.MediaRecorder.AudioSource.DEFAULT

The default pre-processing effects applied for each AudioSource are specified in the /system/etc/audio_effects.conf file. To specify your own default effects for every AudioSource, create a /system/vendor/etc/audio_effects.conf file and specify the pre-processing effects to turn on. For an example, see the implementation for the Nexus 10 in device/samsung/manta/audio_effects.conf. AudioEffect instances acquire and release a session when created and destroyed, enabling the effects (such as the Loudness Enhancer) to persist throughout the duration of the session.

Warning: For the VOICE_RECOGNITION use case, do not enable the noise suppression pre-processing effect. It should not be turned on by default when recording from this audio source, and you should not enable it in your own audio_effects.conf file. Turning on the effect by default will cause the device to fail the compatibility requirement regardless of whether this was on by default due to configuration file , or the audio HAL implementation's default behavior.

The following example enables pre-processing for the VoIP AudioSource and Camcorder AudioSource. By declaring the AudioSource configuration in this manner, the framework will automatically request from the audio HAL the use of those effects.

pre_processing {
   voice_communication {
       aec {}
       ns {}
   }
   camcorder {
       agc {}
   }
}

Source tuning

AudioSource tuning does not have explicit requirements on audio gain or audio processing with the exception of voice recognition (VOICE_RECOGNITION). Requirements for voice recognition include:

  • Flat frequency response (+/- 3dB) from 100Hz to 4kHz
  • Close-talk config: 90dB SPL reads RMS of 2500 (16bit samples)
  • Level tracks linearly from -18dB to +12dB relative to 90dB SPL
  • THD < 1% (90dB SPL in 100 to 4000Hz range)
  • Near-ultrasound requirements (for testing, see Near Ultrasound Tests):
    • Support for SUPPORT_PROPERTY_MIC_NEAR_ULTRASOUND as defined in section 7.8.3 of the CDD.
    • Support one or both of 44100 or 48000 sampling rates with no band-pass or anti-aliasing filters.
  • Effects/pre-processing must be disabled by default

Examples of tuning different effects for different sources are:

  • Noise Suppressor
    • Tuned for wind noise suppressor for CAMCORDER
    • Tuned for stationary noise suppressor for VOICE_COMMUNICATION
  • Automatic Gain Control
    • Tuned for close-talk for VOICE_COMMUNICATION and main phone mic
    • Tuned for far-talk for CAMCORDER

Resources

For more information, refer to the following resources: