首页 技术 正文
技术 2022年11月16日
0 收藏 919 点赞 3,941 浏览 5252 个字

这个其实就是从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 componentapm-> echo_cancellation () -> Enable (true); // Enable echo cancellation moduleapm-> 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 enabledapm-> noise_suppression () -> Enable (true); // noise suppression components, client must be enabledapm-> voice_detection () -> Enable (true); // enable voice detection component, to detect whether there voicesapm-> 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 streamapm-> 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 themt_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 ProcessStreamns_speech_prob = apm-> noise_suppression () -> speech_probability (); // returns the internal voice priority calculated the probability of the current frame. 3.AudioProcessing releaseAudioProcessing :: 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://rg4.net/archives/738.html 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,AGChttp://www.voidcn.com/blog/moming_2013/article/p-4959759.html 回音消除算法的delay值说明http://www.voidcn.com/blog/moming_2013/article/p-3435016.html Android回音噪音处理Demo https://github.com/xiaomo/AudioProcess

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,031
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,520
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,368
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,148
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,781
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,860