📄 ec_main.cc
字号:
// file: ec_main.cc//// system include files//#include <stdio.h>#include <stdlib.h>#include <memory.h>#include <math.h>// local include files//#include "ec.h"#include "ec_constants.h"//-----------------------------------------------------------------------------//// program: ec_main.cc// synopsis: echoc.exe// descr: removes echo from a stero file (see below)// example: ec.exe < foo_stereo_echo.raw > foo_stereo_clean.raw//// options: none//// arguments: none//// note:// this program is a fairly hardcoded implementation of a standard// echo canceller. stdin and stdout are used to I/O. The input signal// is assumed to be of the following form://// - interleaved 16-bit two-channel samples// - the first two bytes correspond to the reference signal// - the second two bytes correspond to the signal plus echo (channel 1)//// the output signal consists of the echo cancelled channel 1 data.////-----------------------------------------------------------------------------main(int argc) { //--------------------------------------------------------------------------- // // process the command line arguments // //--------------------------------------------------------------------------- // check the number of arguments // if (argc != NARGS) { fprintf(stderr, "usage: ec.exe < input_file.raw > output_file.raw\n"); return(1); } // declare an echo canceller object for the reference far-end speech and // the near-end speech // Echo_canceller ec_ref; Echo_canceller ec_near; // initialize the echo canceller // ec_ref.init_cc(DEFAULT_GAMMA, DEFAULT_N, DEFAULT_M, DEFAULT_BETA1, DEFAULT_SIGMA_LY, DEFAULT_SIGMA_LU, DEFAULT_ALPHA_ST, DEFAULT_ALPHA_YT, DEFAULT_CUTOFF, DEFAULT_HANGT, DEFAULT_SUPPR, DEFAULT_TAU); ec_near.init_cc(DEFAULT_GAMMA, DEFAULT_N, DEFAULT_M, DEFAULT_BETA1, DEFAULT_SIGMA_LY, DEFAULT_SIGMA_LU, DEFAULT_ALPHA_ST, DEFAULT_ALPHA_YT, DEFAULT_CUTOFF, DEFAULT_HANGT, DEFAULT_SUPPR, DEFAULT_TAU); //--------------------------------------------------------------------------- // // process data // //--------------------------------------------------------------------------- // main echo cancellation loop // short int sig_in[NCHAN]; short int sig_out[NCHAN]; while (fread(sig_in, NCHAN*sizeof(short int), (int)1, stdin) > (unsigned int)0) { // split the data // double ref = AMPL_SCALE_1 * (double)sig_in[C_R]; double sig = AMPL_SCALE_1 * (double)sig_in[C_E]; // process the data // sig_out[C_E] = ec_ref.clip_cc(ec_ref.process_cc(ref, sig)); sig_out[C_R] = ec_near.clip_cc(ec_near.process_cc(sig, ref)); // write the output data // fwrite(&sig_out, NCHAN*sizeof(short int), (int)1, stdout); } // exit gracefully // return(0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -