📄 ec_main.cc,v
字号:
head 1.8;access;symbols;locks; strict;comment @// @;1.8date 2003.04.12.21.59.01; author hamaker; state Exp;branches;next 1.7;1.7date 97.01.06.00.24.42; author ganapath; state Exp;branches;next 1.6;1.6date 97.01.03.21.12.36; author ganapath; state Exp;branches;next 1.5;1.5date 96.12.28.04.20.49; author ganapath; state Exp;branches;next 1.4;1.4date 96.11.05.17.25.02; author ganapath; state Exp;branches;next 1.3;1.3date 96.11.05.17.20.53; author ganapath; state Exp;branches;next 1.2;1.2date 96.11.05.12.41.20; author picone; state Exp;branches;next 1.1;1.1date 96.11.05.12.18.40; author picone; state Exp;branches;next ;desc@initial version.@1.8log@no change@text@// 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);}@1.7log@added a suppr_ceil parameter and a minimum db value.@text@a80 1 @1.6log@*** empty log message ***@text@d94 1a94 2 //sig_out[C_R] = 0; @1.5log@*** empty log message ***@text@d94 1@1.4log@changed error message when user does not use the correct command line.@text@d49 2a50 2 if (argc > NARGS) { fprintf(stderr, "usage: ec.exe < input_file.raw > output_file.raw\n");a53 1 @1.3log@made the code stdin/stdout based. added new object to process bothchannels for echo.@text@d39 1a39 1main(int argc, char** argv) {d49 1a49 2 if (argc > 1) { fprintf(stderr, "number of arguments must be %d\n", NARGS);@1.2log@changed to floats to doubles.@text@d21 1a21 1// example: echoc.exe < foo_stereo_echo.raw > foo_clean_mono.rawd49 1a49 1 if (argc != NARGS) {d51 1a51 1 fprintf(stderr, "usage: ec.exe <input_file> <output_file>\n");d55 3a57 1 // open input and output filesd59 2a60 2 FILE* fp_in = fopen(argv[1],"r"); FILE* fp_out = fopen(argv[2],"w");a61 4 // declare an echo canceller object // Echo_canceller ec;d64 9a72 5 ec.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);d78 1a78 1d82 3a84 2 while (fread(sig_in, NCHAN*sizeof(short int), (int)1, fp_in) >d91 1a91 1d94 3a96 2 short int sig_out = ec.clip_cc(ec.process_cc(ref, sig));d99 1a99 1 fwrite(&sig_out, SAMPLE_SIZE, (int)1, fp_out);@1.1log@Initial revision@text@d86 2a87 2 float ref = AMPL_SCALE_1 * (float)sig_in[C_R]; float sig = AMPL_SCALE_1 * (float)sig_in[C_E];@
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -