[zaptel-commits] trunk r968 - /trunk/mg2ec.h

zaptel-commits at lists.digium.com zaptel-commits at lists.digium.com
Fri Feb 24 12:48:17 MST 2006


Author: mattf
Date: Fri Feb 24 13:48:16 2006
New Revision: 968

URL: http://svn.digium.com/view/zaptel?rev=968&view=rev
Log:
Add DC normalizing filter to the beginning of the echo canceler (Thanks SteveU!)

Modified:
    trunk/mg2ec.h

Modified: trunk/mg2ec.h
URL: http://svn.digium.com/view/zaptel/trunk/mg2ec.h?rev=968&r1=967&r2=968&view=diff
==============================================================================
--- trunk/mg2ec.h (original)
+++ trunk/mg2ec.h Fri Feb 24 13:48:16 2006
@@ -155,6 +155,7 @@
 	short lastsig[256];
 	int lastpos;
 	int backup;
+	int dc_estimate;
 
 };
 
@@ -257,9 +258,16 @@
 
 static inline void echo_can_free(struct echo_can_state *ec)
 {
+	printk("EC: DC bias calculated: %d V\n", ec->dc_estimate >> 15);
 	FREE(ec);
 }
 
+short inline dc_removal(int *dc_estimate, short samp)
+{
+	*dc_estimate += ((((int)samp << 15) - *dc_estimate) >> 9);
+	return samp - (*dc_estimate >> 15);
+}
+
 static inline short echo_can_update(struct echo_can_state *ec, short iref, short isig) 
 {
 
@@ -274,6 +282,8 @@
 	int Py_i;
 	/* ... */
 	int two_beta_i;
+
+	isig = dc_removal(&ec->dc_estimate, isig);
 	
 	/* flow A on pg. 428 */
 	/* eq. (16): high-pass filter the input to generate the next value;
@@ -646,7 +656,7 @@
 									2 * sizeof(short) * (1 << DEFAULT_ALPHA_ST_I) + /* s_s */
 									2 * sizeof(short) * (maxu) +		/* u_s */
 									2 * sizeof(short) * len);			/* y_tilde_s */
-	  init_cc(ec, len, maxy, maxu);
+		init_cc(ec, len, maxy, maxu);
 	}
 	return ec;
 }



More information about the zaptel-commits mailing list