diff options
-rw-r--r-- | mg2ec.h | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -41,6 +41,7 @@ #define FREE(a) free(a) #endif + #define ABS(a) abs(a!=-32768?a:-32767) #define RESTORE_COEFFS {\ @@ -64,6 +65,8 @@ /* Bring in definitions for the various constants and thresholds */ #include "mg2ec_const.h" +#define DC_NORMALIZE + #ifndef NULL #define NULL 0 #endif @@ -155,7 +158,9 @@ struct echo_can_state { short lastsig[256]; int lastpos; int backup; +#ifdef DC_NORMALIZE int dc_estimate; +#endif }; @@ -258,15 +263,19 @@ static inline void init_cc(struct echo_can_state *ec, int N, int maxy, int maxu) static inline void echo_can_free(struct echo_can_state *ec) { +#ifdef DC_NORMALIZE printk("EC: DC bias calculated: %d V\n", ec->dc_estimate >> 15); +#endif FREE(ec); } +#ifdef DC_NORMALIZE short inline dc_removal(int *dc_estimate, short samp) { *dc_estimate += ((((int)samp << 15) - *dc_estimate) >> 9); return samp - (*dc_estimate >> 15); } +#endif static inline short echo_can_update(struct echo_can_state *ec, short iref, short isig) { @@ -283,7 +292,9 @@ static inline short echo_can_update(struct echo_can_state *ec, short iref, short /* ... */ int two_beta_i; +#ifdef DC_NORMALIZE isig = dc_removal(&ec->dc_estimate, isig); +#endif /* flow A on pg. 428 */ /* eq. (16): high-pass filter the input to generate the next value; |