diff dsp/rateconversion/Decimator.cpp @ 280:9c403afdd9e9

* Various fixes related to the bar estimator code
author Chris Cannam <c.cannam@qmul.ac.uk>
date Tue, 10 Feb 2009 16:37:11 +0000
parents a98a8fe967c0
children e5907ae6de17
line wrap: on
line diff
--- a/dsp/rateconversion/Decimator.cpp	Tue Feb 10 12:52:43 2009 +0000
+++ b/dsp/rateconversion/Decimator.cpp	Tue Feb 10 16:37:11 2009 +0000
@@ -170,6 +170,28 @@
 
 }
 
+void Decimator::doAntiAlias(const float *src, double *dst, unsigned int length)
+{
+
+    for( unsigned int i = 0; i < length; i++ )
+    {
+	Input = (double)src[ i ];
+
+	Output = Input * b[ 0 ] + o1;
+
+	o1 = Input * b[ 1 ] - Output * a[ 1 ] + o2;
+	o2 = Input * b[ 2 ] - Output * a[ 2 ] + o3;
+	o3 = Input * b[ 3 ] - Output * a[ 3 ] + o4;
+	o4 = Input * b[ 4 ] - Output * a[ 4 ] + o5;
+	o5 = Input * b[ 5 ] - Output * a[ 5 ] + o6;
+	o6 = Input * b[ 6 ] - Output * a[ 6 ] + o7;
+	o7 = Input * b[ 7 ] - Output * a[ 7 ] ;
+
+	dst[ i ] = Output;
+    }
+
+}
+
 void Decimator::process(const double *src, double *dst)
 {
     if( m_decFactor != 1 )
@@ -183,3 +205,17 @@
 	dst[ idx++ ] = decBuffer[ m_decFactor * i ];
     }
 }
+
+void Decimator::process(const float *src, float *dst)
+{
+    if( m_decFactor != 1 )
+    {
+	doAntiAlias( src, decBuffer, m_inputLength );
+    }
+    unsigned idx = 0;
+
+    for( unsigned int i = 0; i < m_outputLength; i++ )
+    {
+	dst[ idx++ ] = decBuffer[ m_decFactor * i ];
+    }
+}