reproduced in the original: Http://www.cnblogs.com/mod109/p/5767867.html#top thank you very much.
The WEBRTC's audio processing module is divided into noise reduction ns (NSX), echo cancellation AEC (Echo control Acem), Audio gain AGC, and Mute detection section . In addition WEBRTC has encapsulated a set of audio processing module APM, if it is not a special need, if users want to use the echo cancellation and other more complex modules, it is best to use all the audio processing module, do not compile part of it separately to avoid wasting valuable time.
But the audio noise reduction, the gain function is simple, also can use directly. This part of the source code is I pull out from the WEBRTC, put alone in the VS2010 project to use. This includes resampling as well as filtering and noise reduction functions. This is part of the direct reuse of the post-use WEBRTC noise reduction function of the code, that is, in fact, this part of the blog only from the previous noise reduction based on some of the sound gain code. So about the introduction of WEBRTC not much to say, if interested can refer to the previous blog post;
The test results are also very good, from a 8000 sample rate song can be seen, its gain before and after the waveform is as follows:
OK, the waveform is quite satisfied with it. But the actual effect, but also need to listen to know.
In fact, the gain is very simple to use, the simple code is as follows:
void Webrtcagctest (char *filename, char *outfilename,int FS) {FILE *INFP = NULL;
FILE *OUTFP = NULL;
Short *pdata = NULL;
Short *poutdata = NULL;
void *agchandle = NULL;
do {webrtcagc_create (&agchandle);
int minlevel = 0;
int maxlevel = 255;
int agcmode = Kagcmodefixeddigital;
Webrtcagc_init (Agchandle, MinLevel, Maxlevel, Agcmode, FS);
webrtcagc_config_t Agcconfig;
Agcconfig.compressiongaindb = 20;
agcconfig.limiterenable = 1;
AGCCONFIG.TARGETLEVELDBFS = 3;
Webrtcagc_set_config (Agchandle, agcconfig);
INFP = fopen (filename, "RB");
int framesize = 80;
PData = (short*) malloc (framesize*sizeof (short));
Poutdata = (short*) malloc (framesize*sizeof (short));
OUTFP = fopen (Outfilename, "WB");
int len = framesize*sizeof (short);
int Miclevelin = 0;
int miclevelout = 0;
while (TRUE) {memset (pData, 0, Len);
Len = Fread (PData, 1, Len, INFP);
if (Len > 0) {int inmiclevel = miclevelout;
int outmiclevel = 0;
uint8_t saturationwarning; int nagcret = webrtcagc_process (Agchandle, PData, NULL, Framesize, Poutdata,null, Inmiclevel, &outmiclevel, 0, &s
aturationwarning);
if (Nagcret! = 0) {printf ("failed in webrtcagc_process\n");
Break
} Miclevelin = Outmiclevel;
Fwrite (Poutdata, 1, Len, OUTFP);
} else {break;
}}} while (0);
Fclose (INFP);
Fclose (OUTFP);
Free (pData);
Free (poutdata);
Webrtcagc_free (Agchandle); }
Of course, this code is only for the 8K and 16K sample rate of audio, if the 32K sampling rate needs to use the Filter division, and then passed in the last pass, the specific usage and noise reduction is the same reason, so I will not be listed separately. Specific usage can download the source code attached to this article, refer to 32K sample rate audio noise reduction using the method.
SOURCE Download: Webrtcaudiotest.rar