Mercurial > hg > svcore
comparison data/model/test/TestWaveformOversampler.h @ 1540:a53bf95f0bea zoom
Further test
author | Chris Cannam |
---|---|
date | Thu, 27 Sep 2018 15:19:39 +0100 |
parents | 0b08bc8741c6 |
children | 074b860a7828 |
comparison
equal
deleted
inserted
replaced
1539:0b08bc8741c6 | 1540:a53bf95f0bea |
---|---|
32 m_source = floatvec_t(5000, 0.f); | 32 m_source = floatvec_t(5000, 0.f); |
33 m_source[0] = 1.f; | 33 m_source[0] = 1.f; |
34 m_source[2500] = 0.5f; | 34 m_source[2500] = 0.5f; |
35 m_source[2501] = -0.5f; | 35 m_source[2501] = -0.5f; |
36 m_source[4999] = -1.f; | 36 m_source[4999] = -1.f; |
37 for (int i = 4000; i < 4900; ++i) { | 37 for (int i = 3000; i < 3900; ++i) { |
38 m_source[i] = float(sin(double(i - 1000) * M_PI / 50.0)); | 38 m_source[i] = float(sin(double(i - 3000) * M_PI / 50.0)); |
39 } | 39 } |
40 m_sourceModel = new WritableWaveFileModel(8000, 1); | 40 m_sourceModel = new WritableWaveFileModel(8000, 1); |
41 const float *d = m_source.data(); | 41 const float *d = m_source.data(); |
42 QVERIFY(m_sourceModel->addSamples(&d, m_source.size())); | 42 QVERIFY(m_sourceModel->addSamples(&d, m_source.size())); |
43 m_sourceModel->writeComplete(); | 43 m_sourceModel->writeComplete(); |
197 | 197 |
198 // check for windowed sinc values between the original | 198 // check for windowed sinc values between the original |
199 // samples, even when the original sample that was the source | 199 // samples, even when the original sample that was the source |
200 // of this sinc kernel is not within the requested range | 200 // of this sinc kernel is not within the requested range |
201 floatvec_t output = get(1, 10, 4); | 201 floatvec_t output = get(1, 10, 4); |
202 QVERIFY(output[0] < 0.0001); | |
202 QVERIFY(output[1] + 0.1787 < 0.0001); | 203 QVERIFY(output[1] + 0.1787 < 0.0001); |
203 QVERIFY(output[2] + 0.2099 < 0.0001); | 204 QVERIFY(output[2] + 0.2099 < 0.0001); |
204 QVERIFY(output[3] + 0.1267 < 0.0001); | 205 QVERIFY(output[3] + 0.1267 < 0.0001); |
206 | |
207 // and again at the end | |
208 output = get(4989, 10, 4); | |
209 QVERIFY(output[39] + 0.9000 < 0.0001); | |
210 QVERIFY(output[38] + 0.6358 < 0.0001); | |
211 QVERIFY(output[37] + 0.2993 < 0.0001); | |
212 QVERIFY(output[35] - 0.1787 < 0.0001); | |
213 QVERIFY(output[34] - 0.2099 < 0.0001); | |
214 QVERIFY(output[33] - 0.1267 < 0.0001); | |
205 } | 215 } |
206 | 216 |
207 void testOverlaps4x() { | 217 void testOverlaps4x() { |
208 // overlapping the start -> result should be zero-padded to | 218 // overlapping the start -> result should be zero-padded to |
209 // preserve start frame | 219 // preserve start frame |