webrtc(二) ns
2015-12-03 21:46
302 查看
版本对应的commit
由于缺少说明文档和参考文献,这里简单罗列一下使用的例子
代码使用流程参考webrtc/modules/audio_processing/noise_suppression_impl.cc
commit 99f8566524b3764bf84b7f4cbd8232bdf6c142a5 Author: kjellander <kjellander@webrtc.org> Date: Sun Nov 29 20:50:44 2015 -0800
由于缺少说明文档和参考文献,这里简单罗列一下使用的例子
int nsTest(char *filename, char *outfilename, int mode) { //alloc FILE *infp=fopen(filename,"r"); int nBands = 1; int frameSize = 160;//10ms对应于160个short short *temp = (short*)malloc(frameSize*sizeof(short)); float **pData = (float**)malloc(nBands*sizeof(float*)); pData[0] = (float*)malloc(frameSize*sizeof(float)); float **pOutData = (float**)malloc(nBands*sizeof(float*)); pOutData[0] = (float*)malloc(frameSize*sizeof(float)); int offset = 0; //init NsHandle *handle = 0; int ret = 0; handle=WebRtcNs_Create(); ret= WebRtcNs_Init(handle,16000); if(ret==-1){ printf("%s","init failure!"); return -1; } ret = WebRtcNs_set_policy(handle,2); //process FILE *outfp = fopen(outfilename,"w"); int len = frameSize; while(len > 0) { memset(temp, 0, frameSize*sizeof(short)); len = fread(temp, sizeof(short), frameSize, infp); int i; for(i = 0; i < frameSize; i++) { pData[0][i] = (float)temp[i]; //fprintf(stdout, "ns:%d\n", temp[i]); } WebRtcNs_AnalyzeCore((NoiseSuppressionC*)handle,pData[0]); WebRtcNs_Process(handle,pData,nBands,pOutData); for(i = 0; i < frameSize; i++) { temp[i] = (short)pOutData[0][i]; //fprintf(stderr, "ns:%d\n", temp[i]); } //write file len = fwrite(temp,sizeof(short),len,outfp); } fclose(infp); fclose(outfp); WebRtcNs_Free(handle); free(temp); free(pData[0]); free(pData); free(pOutData[0]); free(pOutData); }
代码使用流程参考webrtc/modules/audio_processing/noise_suppression_impl.cc
相关文章推荐
- http文件头详解http://www.cnblogs.com/tiwlin/archive/2009/09/06/1561279.html
- 关于Intent的使用
- 预处理
- UISegmentedControl
- dedecms织梦特定条件下,隐藏特定栏目的方法,通过css实现
- codeforces604C Alternative Thinking (脑洞大开 )
- 浅谈面向对象(java)
- EM 算法在GMM中的应用
- 日记
- Android集成支付宝
- qmake编译选项的控制(debug|release)
- 一些漂亮的js库
- Android之mvp和mvc对比分析以及实际应用
- 练习E-5
- Android第三方开源FloatingActionButton(com.getbase.floatingactionbutton)【1】
- 图的搜索
- 京东咚咚架构演进
- 图的搜索
- 【Objective-C学习记录】第二天
- 默认实参,constexpr函数