Mercurial > hg > qm-dsp
comparison dsp/rateconversion/Decimator.cpp @ 499:af5b7ef02aa7
Style fixes: avoid unsigned, fix formatting
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Mon, 03 Jun 2019 14:20:39 +0100 |
parents | fdaa63607c15 |
children | 12b5a9244bb0 |
comparison
equal
deleted
inserted
replaced
498:8b92623e81c9 | 499:af5b7ef02aa7 |
---|---|
19 | 19 |
20 ////////////////////////////////////////////////////////////////////// | 20 ////////////////////////////////////////////////////////////////////// |
21 // Construction/Destruction | 21 // Construction/Destruction |
22 ////////////////////////////////////////////////////////////////////// | 22 ////////////////////////////////////////////////////////////////////// |
23 | 23 |
24 Decimator::Decimator( unsigned int inLength, unsigned int decFactor ) | 24 Decimator::Decimator( int inLength, int decFactor ) |
25 { | 25 { |
26 m_inputLength = 0; | 26 m_inputLength = 0; |
27 m_outputLength = 0; | 27 m_outputLength = 0; |
28 m_decFactor = 1; | 28 m_decFactor = 1; |
29 | 29 |
33 Decimator::~Decimator() | 33 Decimator::~Decimator() |
34 { | 34 { |
35 deInitialise(); | 35 deInitialise(); |
36 } | 36 } |
37 | 37 |
38 void Decimator::initialise( unsigned int inLength, unsigned int decFactor) | 38 void Decimator::initialise( int inLength, int decFactor) |
39 { | 39 { |
40 m_inputLength = inLength; | 40 m_inputLength = inLength; |
41 m_decFactor = decFactor; | 41 m_decFactor = decFactor; |
42 m_outputLength = m_inputLength / m_decFactor; | 42 m_outputLength = m_inputLength / m_decFactor; |
43 | 43 |
150 Input = Output = 0; | 150 Input = Output = 0; |
151 | 151 |
152 o1=o2=o3=o4=o5=o6=o7=0; | 152 o1=o2=o3=o4=o5=o6=o7=0; |
153 } | 153 } |
154 | 154 |
155 void Decimator::doAntiAlias(const double *src, double *dst, unsigned int length) | 155 void Decimator::doAntiAlias(const double *src, double *dst, int length) |
156 { | 156 { |
157 for( unsigned int i = 0; i < length; i++ ) { | 157 for (int i = 0; i < length; i++ ) { |
158 | 158 |
159 Input = (double)src[ i ]; | 159 Input = (double)src[ i ]; |
160 | 160 |
161 Output = Input * b[ 0 ] + o1; | 161 Output = Input * b[ 0 ] + o1; |
162 | 162 |
170 | 170 |
171 dst[ i ] = Output; | 171 dst[ i ] = Output; |
172 } | 172 } |
173 } | 173 } |
174 | 174 |
175 void Decimator::doAntiAlias(const float *src, double *dst, unsigned int length) | 175 void Decimator::doAntiAlias(const float *src, double *dst, int length) |
176 { | 176 { |
177 for( unsigned int i = 0; i < length; i++ ) { | 177 for (int i = 0; i < length; i++ ) { |
178 | 178 |
179 Input = (double)src[ i ]; | 179 Input = (double)src[ i ]; |
180 | 180 |
181 Output = Input * b[ 0 ] + o1; | 181 Output = Input * b[ 0 ] + o1; |
182 | 182 |
193 } | 193 } |
194 | 194 |
195 void Decimator::process(const double *src, double *dst) | 195 void Decimator::process(const double *src, double *dst) |
196 { | 196 { |
197 if (m_decFactor == 1) { | 197 if (m_decFactor == 1) { |
198 for( unsigned int i = 0; i < m_outputLength; i++ ) { | 198 for (int i = 0; i < m_outputLength; i++ ) { |
199 dst[i] = src[i]; | 199 dst[i] = src[i]; |
200 } | 200 } |
201 return; | 201 return; |
202 } | 202 } |
203 | 203 |
204 doAntiAlias( src, decBuffer, m_inputLength ); | 204 doAntiAlias( src, decBuffer, m_inputLength ); |
205 | 205 |
206 unsigned idx = 0; | 206 unsigned idx = 0; |
207 | 207 |
208 for( unsigned int i = 0; i < m_outputLength; i++ ) { | 208 for (int i = 0; i < m_outputLength; i++ ) { |
209 dst[ idx++ ] = decBuffer[ m_decFactor * i ]; | 209 dst[ idx++ ] = decBuffer[ m_decFactor * i ]; |
210 } | 210 } |
211 } | 211 } |
212 | 212 |
213 void Decimator::process(const float *src, float *dst) | 213 void Decimator::process(const float *src, float *dst) |
214 { | 214 { |
215 if (m_decFactor == 1) { | 215 if (m_decFactor == 1) { |
216 for( unsigned int i = 0; i < m_outputLength; i++ ) { | 216 for (int i = 0; i < m_outputLength; i++ ) { |
217 dst[i] = src[i]; | 217 dst[i] = src[i]; |
218 } | 218 } |
219 return; | 219 return; |
220 } | 220 } |
221 | 221 |
222 doAntiAlias( src, decBuffer, m_inputLength ); | 222 doAntiAlias( src, decBuffer, m_inputLength ); |
223 | 223 |
224 unsigned idx = 0; | 224 int idx = 0; |
225 | 225 |
226 for( unsigned int i = 0; i < m_outputLength; i++ ) { | 226 for (int i = 0; i < m_outputLength; i++ ) { |
227 dst[ idx++ ] = decBuffer[ m_decFactor * i ]; | 227 dst[ idx++ ] = decBuffer[ m_decFactor * i ]; |
228 } | 228 } |
229 } | 229 } |