www.pudn.com > aec.rar > ec.h


// file: echoc.h
//
// this file defines an echo canceller class. this is a faithful implementation
// of the following application note:
//
//	Messerschmitt, David; Hedberg, David; Cole, Christopher;
//	Haoui, Amine; Winship, Peter; "Digital Voice Echo Canceller
//	with a TMS32020," in Digital Signal Processing Applications
//	with the TMS320 Family, pp. 415-437, Texas Instruments, Inc., 1986.
//
// the code parallels the description of this algorithm quite closely,
// including parameter names.
// 

// make sure definitions are only made once
//
#ifndef __ECHOC
#define __ECHOC

// local include files
//
#include "cb.h"

// class definition
//
class Echo_canceller {

  //---------------------------------------------------------------------------
  //
  // protected data
  //
  //---------------------------------------------------------------------------
protected:

  // filter coefficients
  //
  double *a_d;

  // absolute time
  //
  int i_d;
  double start_speech_d;
 
  int k_i; 
    
  // pre-computed constants
  //
  double gamma_d;
  int N_d;
  int M_d;
  double beta1_d;
  double beta2_d;
  double tau_d;
  int flag_d;
  double sigma_Ly_d;
  double sigma_Lu_d;
  double alpha_st_d;
  double alpha_yt_d;
  double CUTOFF_d;
  int HANGT_d;
  double SUPPR_d;

  // declare memory for the high-pass filter
  //
  double s_i_d;
  double sdc_d;
  double sdc_im1_d;

  // circular buffers
  //
  Circular_buffer y_d;
  Circular_buffer s_d;
  Circular_buffer u_d;
  Circular_buffer e_d;
  Circular_buffer y_tilde_d;

  // declare accumulators for power computations
  //
  double Ly_d;
  double Lu_d;

  // declare an accumulator for the near-end signal detector
  //
  double s_tilde_d;
  int HCNTR_d;

  //---------------------------------------------------------------------------
  //
  // public methods
  //
  //---------------------------------------------------------------------------
public:

  // constructors/destructors
  //
  Echo_canceller();
  ~Echo_canceller();

  // initialization
  //
  void init_cc(double gamma, int N, int M, double beta1,
	       double sigma_ly, double sigma_lu,
	       double alpha_st, double alpha_yt, double cutoff,
	       int hangt, double suppr, double alpha1);

  // computation
  //
  double process_cc(double y, double u);

  // miscellaneous methods
  //
  int max_cc(int x, int y);
  double max_cc(double x, double y);
  short int clip_cc(double value);

  //---------------------------------------------------------------------------
  //
  // private methods
  //
  //---------------------------------------------------------------------------
private:

  // none
};

//
// end of include file
#endif