Android Audio回声消除学习笔记

来源:互联网 发布:剑三萝莉脸型数据网盘 编辑:程序博客网 时间:2024/04/30 17:58

回声消除AcousticEchoCanceler 继承自AudioEffect

声学回声消除器(AEC)AcousticEchoCanceler类消除了从远程捕捉到音频信号上的信号的作用

自动增益控制(AGC)AutomaticGainControl类自动恢复正常捕获的信号输出

噪声抑制器(NC)NoiseSuppressor类可以消除被捕获信号的背景噪音

注意:并不能保证所有的设备都能支持这些效果的,所以你应该首先调用在对应音频效果类上的isAvailable()的方法来检测它的可用性。


AcousticEchoCanceler使用方法

1. 首先判断下设备是否支持回声消除

public static boolean isDeviceSupport(){        return AcousticEchoCanceler.isAvailable();}

2. 初始化并使能AEC

private AcousticEchoCanceler cancelerpublic boolean initAEC( int audioSession){   if(canceler != null)   {        return false;   }   canceler = AcousticEchoCanceler.create(audioSession);   canceler.setEnabled(true);   return canceler.getEnabled();}ps: audioSession的获取   AudioSystem audioSystem        = AudioSystem.getAudioSystem( AudioSystem.LOCATOR_PROTOCOL_AUDIORECORD);  audioSession = audioSystem.getAudioSessionId();

3. 使能/去使能AEC

public boolean setAECEnabled( boolean enable){    if( null == canceler){         return false;    }    canceler.setEnabled(enable);    return canceler.getEnabled();}

4.释放AEC

public boolean release(){    if( null == canceler){        return false;    }    canceler.setEnabled(false);    canceler.release();    return true;}

配置文件记得添加权限

<uses-permission android:name="android.permission.RECORD_AUDIO" />

android新版本增加的API AcousticEchoCanceler 可以非常快速的开发出符合VOIP性质的回声消除程序。但是考虑到各种机型适配,仍然需要第三方的回声消除程序。

这里主要推荐两个:webrtc里面的AEC/AECM,speex。


 

0 0
原创粉丝点击