We are testing built-in AEC (Acoustic Echo Canceler) on Samsung Tab A9+ (Model: SM-X210, Android 10).
When AEC is enabled, the human voice is significantly suppressed during music playback from a separate app (B.apk).
Our goal is to enable AEC while preserving the human voice clearly, even when music is playing.
Setup
- apk – Recorder with AEC and NS enabled
if (android_recorder == null) {
AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION); // Required for AEC?
android_recorder = new AudioRecord(
MediaRecorder.AudioSource.VOICE_COMMUNICATION, // AEC-supported source 16000, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT, bufferSize * 2
);
}
// Enable built-in AEC
if (AcousticEchoCanceler.isAvailable()) {
AcousticEchoCanceler aec = AcousticEchoCanceler.create(android_recorder.getAudioSessionId());
if (aec != null) {
aec.setEnabled(true); Log.d(TAG, "AEC enabled: " + aec.getEnabled());
}
}
// Enable Noise Suppressor
if (NoiseSuppressor.isAvailable()) {
NoiseSuppressor ns = NoiseSuppressor.create(android_recorder.getAudioSessionId());
if (ns != null) {
ns.setEnabled(true); Log.d(TAG, "NS enabled: " + ns.getEnabled());
}
}
android_recorder.startRecording();
android_recorder.read(buffer, 0, bufferSize, AudioRecord.READ_BLOCKING);
- apk – Playback using ExoPlayer
AudioAttributes audioAttributes = new AudioAttributes.Builder()
.setUsage(C.USAGE_MEDIA) // Also tried C.USAGE_VOICE_COMMUNICATION .setContentType(C.CONTENT_TYPE_MUSIC) .build();
player = new SimpleExoPlayer.Builder(context)
.setAudioAttributes(audioAttributes, /* handleAudioFocus= */ false) .build();
player.setPlayWhenReady(false);
Questions:
- Is there any configuration we are missing to allow AEC to work correctly, while keeping the human voice intact?
- Do we need any specific KNOX permissions?
- How to capture audio playback for AEC to function correctly?
- Can you provide us with sample code?