这个其实就是从Audio_processing.h中拿出来的。
APM should be placed in the signal chain as close to the audio hardware abstraction layer (HAL) as possible.
APM accepts only 16-bit linear PCM audio data in frames of 10 ms.Multiple channels should be interleaved.
Audio Processing instantiation and configuration:    
AudioProcessing * apm = AudioProcessing :: Create (0);
apm-> level_estimator () -> Enable (true); // Enable retries estimation component
apm-> echo_cancellation () -> Enable (true); // Enable echo cancellation module
apm-> echo_cancellation () -> enable_metrics (true); //
apm-> echo_cancellation () -> enable_drift_compensation (true); // Enable clock compensation module (sound capture device clock frequency clock frequency and playback devices may be different)
apm-> gain_control () -> Enable (true); // Enable gain control module, client must enable Oh!
apm-> high_pass_filter () -> Enable (true); // high-pass filter components, DC offset and low frequency noise filtering, client must be enabled
apm-> noise_suppression () -> Enable (true); // noise suppression components, client must be enabled
apm-> voice_detection () -> Enable (true); // enable voice detection component, to detect whether there voices
apm-> voice_detection () -> set_likelihood (VoiceDetection :: kModerateLikelihood); // Set the voice detection threshold, the threshold bigger voice less likely to be ignored, some noise may be treated the same voice.
apm-> Initialize (); // Reserved internal state set by the user in all cases of re-initialization apm, to start processing a new audio stream. After creating the first stream does not necessarily need to call this method.
2.AudioProcessing workflow:
AudioProcessing is event-driven, event into the Initialize event, capturing audio event, rendering the audio event.
 
Initialize event:
apm-> set_sample_rate_hz (sample_rate_hz); // set the sample rate of local and remote audio stream
apm-> echo_cancellation () -> set_device_sample_rate_hz (); // set the sample rate audio equipment, we assume that the audio capture and playback device using the same sampling rate. (Must be called when the drift component is enabled)
apm-> set_num_channels (num_capture_input_channels, num_capture_output_channels);
// set the local and remote audio stream of the number of channels
 
Play event:
apm-> AnalyzeReverseStream (& far_frame)); // analysis of 10ms frame data far end of the audio stream, these data provide a reference for echo suppression. (Enable echo suppression when calling needs)
 
Capture events:
apm-> gain_control () -> set_stream_analog_level (capture_level);
apm-> set_stream_delay_ms (delay_ms + extra_delay_ms); // set the delay in milliseconds between local and remote audio streams of. This delay is the time difference and the distal end of the audio stream between the local audio streams, calculated as:
delay = (t_render – t_analyze) + (t_process – t_capture) ;
Among them
t_analyze end audio stream is time to AnalyzeReverseStream () method;
t_render is just similar to the distal end of the audio frame playback time;
t_capture local audio capture time frame;
t_process is the same time frame was given to local audio ProcessStream () method.
 apm-> echo_cancellation () -> set_stream_drift_samples (drift_samples); // Set the difference between the audio device to capture and playback sampling rate. (Must be called when the drift component is enabled)
int err = apm-> ProcessStream (& near_frame); // processing audio streams, including all aspects of the deal. (Such as gain adjustment, echo cancellation, noise suppression, voice activity detection, high throughput rate without decoding Oh! Do for pcm data processing)
capture_level = apm-> gain_control () -> stream_analog_level (); // under emulation mode, you must call this method after ProcessStream, get the recommended analog value of new audio HAL.
stream_has_voice = apm-> voice_detection () -> stream_has_voice (); // detect whether there is a voice, you must call this method after ProcessStream
ns_speech_prob = apm-> noise_suppression () -> speech_probability (); // returns the internal voice priority calculated the probability of the current frame.
 
3.AudioProcessing release
AudioProcessing :: Destroy (apm);
apm = NULL;
另一个示例
AudioProcessing* apm = AudioProcessing::Create(0);
apm->set_sample_rate_hz(32000);
Super-wideband processing.
// Mono capture and stereo render.
apm->set_num_channels(1, 1);
apm->set_num_reverse_channels(2);
apm->high_pass_filter()->Enable(true);
apm->echo_cancellation()->enable_drift_compensation(false);
apm->echo_cancellation()->Enable(true);
apm->noise_reduction()->set_level(kHighSuppression);
apm->noise_reduction()->Enable(true);
apm->gain_control()->set_analog_level_limits(0, 255);
apm->gain_control()->set_mode(kAdaptiveAnalog);
apm->gain_control()->Enable(true);
apm->voice_detection()->Enable(true);
// Start a voice call...
// ... Render frame arrives bound for the audio HAL ...
apm->AnalyzeReverseStream(render_frame);
// ... Capture frame arrives from the audio HAL ...
// Call required set_stream_ functions.
apm->set_stream_delay_ms(delay_ms);
apm->gain_control()->set_stream_analog_level(analog_level);
apm->ProcessStream(capture_frame);
// Call required stream_ functions.
analog_level = apm->gain_control()->stream_analog_level();
has_voice = apm->stream_has_voice();
// Repeate render and capture processing for the duration of the call...
// Start a new call...
apm->Initialize();
// Close the application...
AudioProcessing::Destroy(apm);
apm = NULL;
参考:
http://www.rosoo.net/a/201504/17270.html webrtc 的回声抵消(aec、aecm)算法简介
http://blog.csdn.net/liulina603/article/details/21019915?locationNum=5&fps=1 DemuxAndMix() 这个函数,主要负责AudioProcess的所有过程,包括Aec,Aecm,AGC

webrtc中APM(AudioProcessing module)的使用2的更多相关文章

  1. webrtc中APM(AudioProcessing module)的使用

    一,实例化和配置 AudioProcessing* apm = AudioProcessing::Create(0); //这里的0指的是channelID,只是一个标注那个通道的表示 apm-> ...

  2. android studio 中移除module和恢复module

    一.移除Android Studio中module 在Android Studio中想要删除某个module时,在Android Studio中选中module,右键发现没有delete,如图: An ...

  3. Android IOS WebRTC 音视频开发总结(八十七)-- WebRTC中丢包重传NACK实现分析

    本文主要介绍WebRTC中丢包重传NACK的实现,作者:weizhenwei ,文章最早发表在编风网,微信ID:befoio 支持原创,转载必须注明出处,欢迎关注我的微信公众号blacker(微信ID ...

  4. Android IOS WebRTC 音视频开发总结(八十六)-- WebRTC中RTP/RTCP协议实现分析

    本文主要介绍WebRTC中的RTP/RTCP协议,作者:weizhenwei ,文章最早发表在编风网,微信ID:befoio 支持原创,转载必须注明出处,欢迎关注我的微信公众号blacker(微信ID ...

  5. webrtc中的带宽自适应算法

    转自:http://www.xuebuyuan.com/1248366.html webrtc中的带宽自适应算法分为两种: 1, 发端带宽控制, 原理是由rtcp中的丢包统计来动态的增加或减少带宽,在 ...

  6. Node.js中exports,module.exports以及require方法

    在Node.js中,使用module.exports.f = ...与使用exports.f = ...是一样的,此时exports就是module.exports的一种简写方式.但是,需要注意的是, ...

  7. WebRTC中的NetEQ

    NetEQ使得WebRTC语音引擎能够快速且高解析度地适应不断变化的网络环境,确保了音质优美且缓冲延迟最小,其集成了自适应抖动控制以及丢包隐藏算法. WebRTC和NetEQ概述 WebRTC Web ...

  8. [转载]Pytorch中nn.Linear module的理解

    [转载]Pytorch中nn.Linear module的理解 本文转载并援引全文纯粹是为了构建和分类自己的知识,方便自己未来的查找,没啥其他意思. 这个模块要实现的公式是:y=xAT+*b 来源:h ...

  9. ULPFEC在WebRTC中的实现[转载]

    一.WebRTC对抗网络丢包的两种手段     丢包重传(NACK)和前向纠错(FEC).FEC是一种前向纠错技术,发送端将负载数据加上一定的冗余纠错码一起发送,接收端根据接收到的纠错码对数据进行差错 ...

随机推荐

  1. PHP框架模板原理

           PHP框架现在是一种很流行的东西了,很多朋友开发应用与网站都会选择一个PHP框架或模板了,下面我们来看看PHP框架是如何实现的吧. 本文主要来聊聊框架理论,但不针对任何一款框架,不过任何 ...

  2. 关于MySQL的wait_timeout连接超时问题报错解决方案

    bug回顾 : 想必大家在用MySQL时都会遇到连接超时的问题,如下图所示: ### Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsExce ...

  3. 我们是怎么管理QQ群的

    文章背景:腾讯平台上的qq群数以千万百万计,但99%的在吹水扯蛋,从早上的问好开始,到晚上的晚安,无一不浪费青春之时间,看之痛心,无力改变,只好自己建了一个,希望能以此来改变群内交流的氛围或环境. 以 ...

  4. [Linux] Linux常用文本操作命令整理

    简单的总结一下常用的一些实用的Linux文本操作命令,包括wc(统计).cut(切分).sort(排序).uniq(去重).grep(查找).sed(替换.插入.删除).awk(文本分析). 1.统计 ...

  5. IIS7.0发布Web服务器0002

    asp.net发布到IIS中出现错误:处理程序“PageHandlerFactory-Integrated”在其模块列表中有一个错误模块“ManagedPipelineHandler” 分类: BS学 ...

  6. MySQL主从复制原理及配置详细过程以及主从复制集群自动化部署的实现

    一.复制概述 Mysql内建的复制功能是构建大型,高性能应用程序的基础.将Mysql的数据分布到多个系统上去,这种分布的机制,是通过将Mysql的某一台主机的数据复制到其它主机(slaves)上,并重 ...

  7. Sublime Text 3 Plugin Better!

    Package Control Cmake ConvertUTF Markdown preview MarkdownEditing Marking Changed Rows

  8. 高程(4):执行环境、作用域、上下文执行过程、垃圾收集、try...catch...

    高程三 4.2.4.3 一.执行环境 1.全局执行环境是最外层的执行环境. 2.每个函数都有自己的执行环境,执行函数时,函数环境就会被推入一个当前环境栈中,执行完毕,栈将其环境弹出,把控制器返回给之前 ...

  9. Ecmascript 6新特性

    声明变量由var变成let.let实际上为JavaScript新增了块级作用域.let与var相比具有的特性有 1.不允许重复声明一个变量 var a=5; var a=7; let b=6; let ...

  10. 项目vue2.0仿外卖APP(四)

    组件拆分 先把项目搭建时生成的代码给清了吧 现在static目录下引入reset.css 接着在index.html引入,并且设置<meta> 有时候呢,为了让代码符合我们平时的编码习惯, ...