AcousticEchoCanceler on Samsung devices not working

I have an AcousticEchoCanceler working for VoIP calls for all other types of devices I tried, but not on any Samsung device. The device reports that AcousticEchoCanceler is available, but it just does nothing.

What I have:

  • acousticEchoCanceler.setEnabled(true);
  • audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
  • Audio Session ID submitted by AudioTrack
  • Sampling Rate: 16k
  • Tried mono and stereo recording
  • <uses-permission android:name="android.permission.RECORD_AUDIO"/>
  • <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>

Has anyone got AcousticEchoCanceler to work on a Samsung device?

+8
android samsung-mobile
source share
3 answers

Try the following lines:

 if (AcousticEchoCanceler.isAvailable() && WebRtcAudioUtils.isAcousticEchoCancelerSupported()) { WebRtcAudioUtils.setWebRtcBasedAcousticEchoCanceler(true); WebRtcAudioUtils.useWebRtcBasedAcousticEchoCanceler(); } 
+1
source share

I tried this code a few years ago and remember that it worked. I can’t say how it will work with the latest devices.

 int audioSource = MediaRecorder.AudioSource.VOICE_COMMUNICATION; int sampleFreq = 16000; int numChannels = 1; int numBytesPerSample = 2; int channelConfig = numChannels == 1 ? AudioFormat.CHANNEL_IN_MONO : AudioFormat.CHANNEL_IN_STEREO; int audioFormat = numBytesPerSample == 2 ? AudioFormat.ENCODING_PCM_16BIT : AudioFormat.ENCODING_PCM_8BIT; int bufSize = AudioRecord.getMinBufferSize(sampleFreq, channelConfig, audioFormat); if (bufSize == AudioRecord.ERROR_BAD_VALUE || bufSize == AudioRecord.ERROR) { return; } AudioRecord audioInRecord = new AudioRecord(audioSource, sampleFreq, channelConfig, audioFormat, bufSize); if (audioInRecord.getState() != AudioRecord.STATE_INITIALIZED) { return; } boolean aecAvailable = AcousticEchoCanceler.isAvailable(); if (aecAvailable) { AcousticEchoCanceler instance; if((instance = AcousticEchoCanceler.create(audioInRecord.getAudioSessionId())) != null) { instance.setEnabled(true); Log.d(TAG, "AEC enabled"); } else { Log.d(TAG, "AEC disabled"); } } 
+1
source share

I have had the same issue recently. The most important part for me was using audioManager.setMode (AudioManager.MODE_IN_COMMUNICATION) before creating AudioRecord.

Then AudioRecord was created using

 mAudioRecord = new AudioRecord(MediaRecorder.AudioSource.VOICE_COMMUNICATION, mSamplingRate, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT, audioRecordBufferSize); 

And finally, create and activate NS and AEC:

 mNoiseSuppressor = NoiseSuppressor.create(mAudioRecord.getAudioSessionId()); if (mNoiseSuppressor != null) { int res = mNoiseSuppressor.setEnabled(true); } mAcousticEchoCanceler = AcousticEchoCanceler.create(mAudioRecord.getAudioSessionId()); if (mAcousticEchoCanceler != null) { int res = mAcousticEchoCanceler.setEnabled(true); } 

AudioTrack need not be associated with the same audio session identifier as AudioTrack (I assume this should be done automatically).

0
source share

All Articles