comparison dsp/rateconversion/Decimator.cpp @ 55:7fe29d8a7eaf

* Various fixes related to the bar estimator code
author cannam
date Tue, 10 Feb 2009 16:37:11 +0000
parents f7edcd9138bd
children e5907ae6de17
comparison
equal deleted inserted replaced
54:5bec06ecc88a 55:7fe29d8a7eaf
168 dst[ i ] = Output; 168 dst[ i ] = Output;
169 } 169 }
170 170
171 } 171 }
172 172
173 void Decimator::doAntiAlias(const float *src, double *dst, unsigned int length)
174 {
175
176 for( unsigned int i = 0; i < length; i++ )
177 {
178 Input = (double)src[ i ];
179
180 Output = Input * b[ 0 ] + o1;
181
182 o1 = Input * b[ 1 ] - Output * a[ 1 ] + o2;
183 o2 = Input * b[ 2 ] - Output * a[ 2 ] + o3;
184 o3 = Input * b[ 3 ] - Output * a[ 3 ] + o4;
185 o4 = Input * b[ 4 ] - Output * a[ 4 ] + o5;
186 o5 = Input * b[ 5 ] - Output * a[ 5 ] + o6;
187 o6 = Input * b[ 6 ] - Output * a[ 6 ] + o7;
188 o7 = Input * b[ 7 ] - Output * a[ 7 ] ;
189
190 dst[ i ] = Output;
191 }
192
193 }
194
173 void Decimator::process(const double *src, double *dst) 195 void Decimator::process(const double *src, double *dst)
174 { 196 {
175 if( m_decFactor != 1 ) 197 if( m_decFactor != 1 )
176 { 198 {
177 doAntiAlias( src, decBuffer, m_inputLength ); 199 doAntiAlias( src, decBuffer, m_inputLength );
181 for( unsigned int i = 0; i < m_outputLength; i++ ) 203 for( unsigned int i = 0; i < m_outputLength; i++ )
182 { 204 {
183 dst[ idx++ ] = decBuffer[ m_decFactor * i ]; 205 dst[ idx++ ] = decBuffer[ m_decFactor * i ];
184 } 206 }
185 } 207 }
208
209 void Decimator::process(const float *src, float *dst)
210 {
211 if( m_decFactor != 1 )
212 {
213 doAntiAlias( src, decBuffer, m_inputLength );
214 }
215 unsigned idx = 0;
216
217 for( unsigned int i = 0; i < m_outputLength; i++ )
218 {
219 dst[ idx++ ] = decBuffer[ m_decFactor * i ];
220 }
221 }