www.pudn.com > aec_fix_zhang.rar > aec.h, change:2008-11-05,size:4769b

#ifndef _AEC_H                  /* include only once */ 
#define _AEC_H 
// dB Values 
#define M0dB  1.0f 
#define M3dB  0.71f 
#define M6dB  0.50f 
#define M9dB  0.35f 
#define M12dB  0.25f 
#define M18dB  0.125f 
#define M24dB  0.063f 
// dB values for 16bit PCM  
// MxdB_PCM = 32767 * 10 ^(x / 20)  
#define M10dB_PCM  10362 
#define M20dB_PCM  3277 
#define M25dB_PCM  1843 
#define M30dB_PCM  1026 
#define M35dB_PCM  583 
#define M40dB_PCM  328 
#define M45dB_PCM  184 
#define M50dB_PCM  104 
#define M55dB_PCM  58 
#define M60dB_PCM  33 
#define M65dB_PCM  18 
#define M70dB_PCM  10 
#define M75dB_PCM  6 
#define M80dB_PCM  3 
#define M85dB_PCM  2 
#define M90dB_PCM  1 
#define MAXPCM  32767 
// Design constants (Change to fine tune the algorithms  
// minimum energy in xf. Range: M70dB_PCM to M50dB_PCM. Should be equal 
// to microphone ambient Noise level  
#define NoiseFloor  M55dB_PCM 
// Adrian soft decision DTD  
// left point. X is ratio, Y is stepsize 
#define STEPX1  1 
#define STEPY1  1 
// right point. STEPX2=2.0 is good double talk, 3.0 is good single talk. 
#define STEPX2  2 
#define STEPY2  0 
#define ALPHAFAST  655//(1.0 / 100.0) 
#define ALPHASLOW  3//(1.0 / 20000.0) 
// Ageing multiplier for LMS memory vector w  
#define Leaky  0.9999f 
// Double Talk Detector Speaker/Microphone Threshold. Range <=1 
// Large value (M0dB) is good for Single-Talk Echo cancellation,  
// small value (M12dB) is good for Doulbe-Talk AEC  
#define GeigelThreshold  M12dB 
// for Non Linear Processor. Range >0 to 1. Large value (M0dB) is good 
// for Double-Talk, small value (M12dB) is good for Single-Talk  
#define NLPAttenuation  M0dB 
// Maxium of Sampling Frequency Type 
// 1 for 8KHz, 2 for 16KHz 
#define MAX_WIDEB 2 
// Maxium of NLMS filter length 
#define MAX_NLMS_LEN  (200 * MAX_WIDEB * 8) 
// Extention in taps to reduce mem copies 
#define NLMS_EXT  (10*8) 
// block size in taps to optimize DTD calculation  
#define DTD_LEN   16 
// Below this line there are no more design constants  
typedef  struct{ 
	float   x;	 
	float   a0; 
typedef  struct{ 
	float   z[36]; 
	float   a[36]; 
} FIR_HP_300Hz; 
typedef  struct{ 
	float   in0, out0; 
	float   a0, a1, b1;		// filter coefficients 
} IIR1_HP; 
typedef  struct   { 
	// Sampling Frequency Type 
	// 1 for 8KHz, 2 for 16KHz 
	int samplFreqType; 
    int RATE;     //   Sampling Frequency 
	// NLMS filter length in taps (samples). A longer filter length gives 
	// better Echo Cancellation, but maybe slower convergence speed and 
	// needs more CPU power (Order of NLMS is linear)  
	int NLMS_LEN; 
	// Vector w visualization length in taps (samples). 
	// Must match argv value for wdisplay.tcl  
	int DUMP_LEN; 
	// Leaky hangover in taps 
	int Thold; 
	// Time domain Filters 
	// Mic signal amplify 
	int gain;                     
	// DC-level remove Highpass 
	IIR_HP_AEC acMic, acSpk; 
	// 150Hz cut-off Highpass 
	FIR_HP_300Hz  cutoff; 
	// pre-whitening Highpass for x, e 
	IIR1_HP Fx, Fe; 
	// soft decision DTD (Double Talk Detector) 
	__int64 dfast, xfast;     
	__int64 dslow, xslow; 
	// NLMS-pw 
	int x[MAX_NLMS_LEN + NLMS_EXT];	// tap delayed loudspeaker signal 
	int xf[MAX_NLMS_LEN + NLMS_EXT];	// pre-whitening tap delayed signal 
	int w[MAX_NLMS_LEN];				// tap weights 
	//float *x;	// tap delayed loudspeaker signal 
	//float *xf;	// pre-whitening tap delayed signal 
	//float *w;				// tap weights 
	int j;								// optimize: less memory copies 
	__int64 dotp_xf_xf;					// double to avoid loss of precision 
	int delta;						// noise floor to stabilize NLMS 
	// Geigel DTD (Double Talk Detector) 
	int hangover; 
	int stepsize; 
// Exponential Smoothing or IIR Infinite Impulse Response Filter 
void IIR_HP_init( IIR_HP_AEC *f ); 
float IIR_HP_apply(IIR_HP_AEC *f, float in );  
// FIR Finite Impulse Response filter 
void FIR_HP_300Hz_init( FIR_HP_300Hz *f, int sft ); 
float FIR_HP_300Hz_apply(FIR_HP_300Hz *f, float in, int sft); 
// Recursive single pole IIR Infinite Impulse response High-pass filter 
void IIR1_HP_init(IIR1_HP *f, float Fc);  
float IIR1_HP_apply(IIR1_HP *f, float in);  
// Acoustic Echo Cancellation functions  
void AEC_init(AECSTATDEF *aec, int sft); 
int AEC_dtd(AECSTATDEF *aec, int d, int x); 
void AEC_leaky(AECSTATDEF *aec); 
int AEC_nlms_pw(AECSTATDEF *aec, int d, int x_, int stepsize); 
int AEC_doAEC(AECSTATDEF *aec, int d_, int x_, int sft); 
void AEC_setambient(AECSTATDEF *aec, int Min_xf) ; 
void AEC_setgain(AECSTATDEF *aec, int gain_);  
void AEC_setSamplFreqType(AECSTATDEF *aec, int sft); 
int AEC_getstepsize(AECSTATDEF *aec); 
int AEC_getambient(AECSTATDEF *aec) ;