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:
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 {} } }
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:
Examples of tuning different effects for different sources are:
CAMCORDER
VOICE_COMMUNICATION
VOICE_COMMUNICATION
and main phone
micCAMCORDER
For more information, refer to the following resources:
device/samsung/manta/audio_effects.conf
file for the Nexus 10