Mercurial > hg > qm-dsp
comparison dsp/rateconversion/TestResampler.cpp @ 372:d464286c007b
Fixes to latency and initial phase calculations (+ explanation)
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Thu, 17 Oct 2013 22:12:36 +0100 |
parents | 192d6b3f4379 |
children | 9db2712b3ce4 |
comparison
equal
deleted
inserted
replaced
371:33e9e964443c | 372:d464286c007b |
---|---|
91 } | 91 } |
92 | 92 |
93 delete[] outPadded; | 93 delete[] outPadded; |
94 delete[] inPadded; | 94 delete[] inPadded; |
95 } | 95 } |
96 | 96 /* |
97 BOOST_AUTO_TEST_CASE(sameRateOneShot) | 97 BOOST_AUTO_TEST_CASE(sameRateOneShot) |
98 { | 98 { |
99 double d[] = { 0, 0.1, -0.3, -0.4, -0.3, 0, 0.5, 0.2, 0.8, -0.1 }; | 99 double d[] = { 0, 0.1, -0.3, -0.4, -0.3, 0, 0.5, 0.2, 0.8, -0.1 }; |
100 testResamplerOneShot(4, 4, 10, d, 10, d, 0); | 100 testResamplerOneShot(4, 4, 10, d, 10, d, 0); |
101 } | 101 } |
147 for (int i = 0; i < 1000; ++i) { | 147 for (int i = 0; i < 1000; ++i) { |
148 out[i] = sin(i * M_PI / 4.0); | 148 out[i] = sin(i * M_PI / 4.0); |
149 } | 149 } |
150 testResamplerOneShot(16, 8, 2000, in, 200, out, 256); | 150 testResamplerOneShot(16, 8, 2000, in, 200, out, 256); |
151 } | 151 } |
152 | 152 */ |
153 vector<double> | 153 vector<double> |
154 squareWave(int rate, double freq, int n) | 154 squareWave(int rate, double freq, int n) |
155 { | 155 { |
156 //!!! todo: hoist, test | 156 //!!! todo: hoist, test |
157 vector<double> v(n, 0.0); | 157 vector<double> v(n, 0.0); |
202 } | 202 } |
203 | 203 |
204 // Don't compare bins any higher than 99% of Nyquist freq of lower sr | 204 // Don't compare bins any higher than 99% of Nyquist freq of lower sr |
205 int lengthOfInterest = (inrate < outrate ? inrate : outrate) / 2; | 205 int lengthOfInterest = (inrate < outrate ? inrate : outrate) / 2; |
206 lengthOfInterest = lengthOfInterest - (lengthOfInterest / 100); | 206 lengthOfInterest = lengthOfInterest - (lengthOfInterest / 100); |
207 /* | 207 |
208 std::cerr << "inSpectrum:" << std::endl; | |
209 for (int i = 0; i < lengthOfInterest; ++i) { | |
210 if (i % 5 == 0) std::cerr << std::endl << i << ": "; | |
211 std::cerr << inSpectrum[i] << " "; | |
212 } | |
213 | |
214 std::cerr << "\noutSpectrum:" << std::endl; | |
215 for (int i = 0; i < lengthOfInterest; ++i) { | |
216 if (i % 5 == 0) std::cerr << std::endl << i << ": "; | |
217 std::cerr << outSpectrum[i] << " "; | |
218 } | |
219 std::cerr << std::endl; | |
220 */ | |
221 for (int i = 0; i < lengthOfInterest; ++i) { | 208 for (int i = 0; i < lengthOfInterest; ++i) { |
222 BOOST_CHECK_SMALL(inSpectrum[i] - outSpectrum[i], 1e-7); | 209 BOOST_CHECK_SMALL(inSpectrum[i] - outSpectrum[i], 1e-7); |
223 } | 210 } |
224 } | 211 } |
225 | 212 |