ec_constants.h
资源名称:aec.rar [点击查看]
上传用户:lqyjxl
上传日期:2015-08-21
资源大小:14k
文件大小:5k
源码类别:
Audio
开发平台:
Visual C++
- // file: echoc_constants.h
- //
- // various constants used in the echo canceller code.
- //
- // make sure definitions are only made once
- //
- #ifndef __ECHOC_CONSTANTS
- #define __ECHOC_CONSTANTS
- //-----------------------------------------------------------------------------
- //
- // i/o related constants begin here
- //
- //-----------------------------------------------------------------------------
- // sampling frequency of input data
- //
- #define SAMPLE_FREQ 8000
- // the maximum magnitude of a speech sample (used to prevent overflow)
- // and a scaling factor to make signals exist in the range [-1,1]
- //
- #define AMPL_SCALE_1 3.0518509e-05
- #define AMPL_SCALE_2 32767.0
- #define MAX_AMPL 1.0
- //-----------------------------------------------------------------------------
- //
- // algorithm constants begin here
- //
- //-----------------------------------------------------------------------------
- // first-order high-pass filter
- //
- #define DEFAULT_GAMMA pow(2.0, -3.0)
- // the number of taps in the echo canceller (N)
- //
- #define DEFAULT_N 8 // 256
- // the number of samples used to update coefficients using the
- // the block update method (M)
- //
- #define DEFAULT_M 8 // 16
- // the adaptation speed (beta1) and max adaptation value
- // note that the max allowable adaptation value needs to be adjusted somewhat
- // depending on the block update interval (the less you update, the more
- // you must perturb the coefficients to keep up - but we shouldn't let
- // this get out of hand or the system goes unstable) It has also been
- // observed that there exits an inverse relationship between beta1 and the
- // filter length we choose. For example when the filter length was 128 a
- // beta1=pow(2.0, -11.0) sufficed to get convergence of the algorithm, but when
- // we used a filter length of 256 we had to lower beta1 to the present value.
- //
- #define DEFAULT_BETA1 pow( 2.0, -10.0 ) // -11, -12 ar ok.
- // constants for the reference and near-end power computation
- //
- #define DEFAULT_SIGMA_LU pow(2.0, -7.0)
- #define DEFAULT_SIGMA_LY pow(2.0, -7.0)
- #define DEFAULT_ALPHA_ST pow(2.0, -5.0)
- #define DEFAULT_ALPHA_YT pow(2.0, -5.0)
- #define DEFAULT_CUTOFF pow(2.0, -15.0)
- // define the near-end speech hangover counter: if near-end speech
- // is declared, hcntr is set equal to hangt (see pg. 432)
- //
- #define DEFAULT_HANGT 600
- // define the residual error suppression threshold
- //
- #define DEFAULT_SUPPR ( 16 )
- //-----------------------------------------------------------------------------
- //
- // changes to the standard lms algorithm are documented here
- // we describe two changes useful for speech recognition research:
- //
- // 1. exponential damping of the adaptation gain
- // 2. residual error suppression based on the near-end speech energy
- //
- //-----------------------------------------------------------------------------
- //
- // in a departure from the standard lms algorithm, we add an
- // exponentially decaying weight to the adaptation constant. this
- // serves to slow the rate of adaptation the further into the file we get.
- //
- // the equation of this decay is:
- //
- // beta_actual = max[beta * exp[-tau*(t - t0 - t_onset)]
- // u(t - t0 - t_onset), MIN_BETA]
- //
- // where tau is the decay constant, and t0 is measured from the first
- // onset of speech
- //
- // define the value of t0 in secs
- //
- #define DEFAULT_T0 5
- // define default value for tau
- //
- #define DEFAULT_TAU 1
- // we also need to define a threshold for which we decide that near-end
- // speech has begun. in a standard echo cancellation algorithm, we have an
- // outgoing signal that is typically larger than the echo. when the
- // outgoing speech is much larger than the echo, we declare this event the
- // onset of speech activity - this is t0. we need a threshold to
- // define this event. we use the ratio of the far-end speech to
- // near-end speech in db.
- //
- #define ONSET_THRESH -20
- // constants for error suppression
- //
- // in a second departure, we calculate the residual error suppression
- // as a percentage of the reference signal energy level. the threshold
- // is defined in terms of dB below the reference signal.
- //
- #define RES_SUPR_FACTOR -20
- // we need a dynamic level of suppression varying with the ratio of the
- // power of the echo to the power of the reference signal
- // this is done so that we have a smoother background.
- // we have a higher suppression when the power ratio is closer to
- // suppr_ceil and reduces logarithmically as we approach suppr_floor.
- //
- #define SUPPR_FLOOR -64
- // #define SUPPR_CEIL -24
- #define SUPPR_CEIL -2
- // to avoid problems when the input data is zeroed out, we have a minimum
- // dB value specified for the ratio of the power of the echo to the power
- // of the reference signal
- //
- #define EC_MIN_DB_VALUE -70
- // end of include file
- #endif