comparison data/model/test/TestWaveformOversampler.h @ 1538:fa67fbbff8fc zoom

Oversampler fixes and further tests
author Chris Cannam
date Wed, 26 Sep 2018 15:11:26 +0100
parents c5092ca1c6e5
children 0b08bc8741c6
comparison
equal deleted inserted replaced
1537:c5092ca1c6e5 1538:fa67fbbff8fc
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 = 4000; i < 4900; ++i) {
38 m_source[i] = sin(double(i - 1000) * M_PI / 50.0); 38 m_source[i] = float(sin(double(i - 1000) * 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();
68 compareStrided(obtained, expected, 1); 68 compareStrided(obtained, expected, 1);
69 } 69 }
70 70
71 floatvec_t get(sv_frame_t sourceStartFrame, 71 floatvec_t get(sv_frame_t sourceStartFrame,
72 sv_frame_t sourceFrameCount, 72 sv_frame_t sourceFrameCount,
73 sv_frame_t oversampleBy) { 73 int oversampleBy) {
74 return WaveformOversampler::getOversampledData 74 return WaveformOversampler::getOversampledData
75 (m_sourceModel, 0, 75 (m_sourceModel, 0,
76 sourceStartFrame, sourceFrameCount, oversampleBy); 76 sourceStartFrame, sourceFrameCount, oversampleBy);
77 } 77 }
78 78
192 192
193 void testSubsets4x() { 193 void testSubsets4x() {
194 testStrided(0, 500, 4, sourceSubset(0, 500)); 194 testStrided(0, 500, 4, sourceSubset(0, 500));
195 testStrided(4500, 500, 4, sourceSubset(4500, 500)); 195 testStrided(4500, 500, 4, sourceSubset(4500, 500));
196 testStrided(2000, 1000, 4, sourceSubset(2000, 1000)); 196 testStrided(2000, 1000, 4, sourceSubset(2000, 1000));
197
198 // check for windowed sinc values between the original
199 // samples, even when the original sample that was the source
200 // of this sinc kernel is not within the requested range
201 floatvec_t output = get(1, 10, 4);
202 QVERIFY(output[1] + 0.1787 < 0.0001);
203 QVERIFY(output[2] + 0.2099 < 0.0001);
204 QVERIFY(output[3] + 0.1267 < 0.0001);
197 } 205 }
198 206
199 void testOverlaps4x() { 207 void testOverlaps4x() {
200 // overlapping the start -> result should be zero-padded to 208 // overlapping the start -> result should be zero-padded to
201 // preserve start frame 209 // preserve start frame