diff options
author | Hans Baier <hansfbaier@googlemail.com> | 2009-06-23 09:50:02 +0000 |
---|---|---|
committer | Hans Baier <hansfbaier@googlemail.com> | 2009-06-23 09:50:02 +0000 |
commit | f42f577bedbffcd2465341e033afac0a0326a491 (patch) | |
tree | 3499d135da2d870010a8231389fb040a22c02218 /libs/ardour/tests/interpolation-test.cc | |
parent | def335e427f46513436884bf81d10caf96d7c482 (diff) |
Interpolation: First working but buggy version using libsamplerate
git-svn-id: svn://localhost/ardour2/branches/3.0@5255 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/tests/interpolation-test.cc')
-rw-r--r-- | libs/ardour/tests/interpolation-test.cc | 62 |
1 files changed, 30 insertions, 32 deletions
diff --git a/libs/ardour/tests/interpolation-test.cc b/libs/ardour/tests/interpolation-test.cc index 5a559cc830..3ec7910e1b 100644 --- a/libs/ardour/tests/interpolation-test.cc +++ b/libs/ardour/tests/interpolation-test.cc @@ -11,56 +11,54 @@ InterpolationTest::linearInterpolationTest () { cout << "\nLinear Interpolation Test\n"; cout << "\nSpeed: 1.0"; - linear.set_speed (1.0); - linear.set_target_speed (linear.speed()); - nframes_t result = linear.interpolate (NUM_SAMPLES, input, output); - CPPUNIT_ASSERT_EQUAL ((uint32_t)(NUM_SAMPLES * linear.speed()), result); + interpolation.set_speed (1.0); + nframes_t result = interpolation.interpolate (0, NUM_SAMPLES, input, output); + CPPUNIT_ASSERT_EQUAL ((uint32_t)(NUM_SAMPLES * interpolation.speed()), result); +/* +*/ + for (int i=0; i < NUM_SAMPLES; ++i) { + cout << "input[" << i << "] = " << input[i] << " output[" << i << "] = " << output[i] << endl; + } for (int i = 0; i < NUM_SAMPLES; i += INTERVAL) { - CPPUNIT_ASSERT_EQUAL (1.0f, output[i]); + CPPUNIT_ASSERT_EQUAL (1.0f, output[i+1]); } cout << "\nSpeed: 0.5"; - linear.set_speed (0.5); - linear.set_target_speed (linear.speed()); - result = linear.interpolate (NUM_SAMPLES, input, output); - CPPUNIT_ASSERT_EQUAL ((uint32_t)(NUM_SAMPLES * linear.speed()), result); - for (int i = 0; i < NUM_SAMPLES; i += (INTERVAL / linear.speed() +0.5)) { + interpolation.set_speed (0.5); + result = interpolation.interpolate (0, NUM_SAMPLES, input, output); + CPPUNIT_ASSERT_EQUAL ((uint32_t)(NUM_SAMPLES * interpolation.speed()), result); + for (int i = 0; i < NUM_SAMPLES; i += (INTERVAL / interpolation.speed() +0.5)) { CPPUNIT_ASSERT_EQUAL (1.0f, output[i]); } cout << "\nSpeed: 0.2"; - linear.set_speed (0.2); - linear.set_target_speed (linear.speed()); - result = linear.interpolate (NUM_SAMPLES, input, output); - CPPUNIT_ASSERT_EQUAL ((uint32_t)(NUM_SAMPLES * linear.speed()), result); + interpolation.set_speed (0.2); + result = interpolation.interpolate (0, NUM_SAMPLES, input, output); + CPPUNIT_ASSERT_EQUAL ((uint32_t)(NUM_SAMPLES * interpolation.speed()), result); cout << "\nSpeed: 0.02"; - linear.set_speed (0.02); - linear.set_target_speed (linear.speed()); - result = linear.interpolate (NUM_SAMPLES, input, output); - CPPUNIT_ASSERT_EQUAL ((uint32_t)(NUM_SAMPLES * linear.speed()), result); + interpolation.set_speed (0.02); + result = interpolation.interpolate (0, NUM_SAMPLES, input, output); + CPPUNIT_ASSERT_EQUAL ((uint32_t)(NUM_SAMPLES * interpolation.speed()), result); cout << "\nSpeed: 0.002"; - linear.set_speed (0.002); - linear.set_target_speed (linear.speed()); - result = linear.interpolate (NUM_SAMPLES, input, output); - CPPUNIT_ASSERT_EQUAL ((uint32_t)(NUM_SAMPLES * linear.speed()), result); + interpolation.set_speed (0.002); + result = interpolation.interpolate (0, NUM_SAMPLES, input, output); + CPPUNIT_ASSERT_EQUAL ((uint32_t)(NUM_SAMPLES * interpolation.speed()), result); cout << "\nSpeed: 2.0"; - linear.set_speed (2.0); - linear.set_target_speed (linear.speed()); - result = linear.interpolate (NUM_SAMPLES / 2, input, output); - CPPUNIT_ASSERT_EQUAL ((uint32_t)(NUM_SAMPLES / 2 * linear.speed()), result); - for (int i = 0; i < NUM_SAMPLES / 2; i += (INTERVAL / linear.speed() +0.5)) { + interpolation.set_speed (2.0); + result = interpolation.interpolate (0, NUM_SAMPLES / 2, input, output); + CPPUNIT_ASSERT_EQUAL ((uint32_t)(NUM_SAMPLES / 2 * interpolation.speed()), result); + for (int i = 0; i < NUM_SAMPLES / 2; i += (INTERVAL / interpolation.speed() +0.5)) { CPPUNIT_ASSERT_EQUAL (1.0f, output[i]); } cout << "\nSpeed: 10.0"; - linear.set_speed (10.0); - linear.set_target_speed (linear.speed()); - result = linear.interpolate (NUM_SAMPLES / 10, input, output); - CPPUNIT_ASSERT_EQUAL ((uint32_t)(NUM_SAMPLES / 10 * linear.speed()), result); - for (int i = 0; i < NUM_SAMPLES / 10; i += (INTERVAL / linear.speed() +0.5)) { + interpolation.set_speed (10.0); + result = interpolation.interpolate (0, NUM_SAMPLES / 10, input, output); + CPPUNIT_ASSERT_EQUAL ((uint32_t)(NUM_SAMPLES / 10 * interpolation.speed()), result); + for (int i = 0; i < NUM_SAMPLES / 10; i += (INTERVAL / interpolation.speed() +0.5)) { CPPUNIT_ASSERT_EQUAL (1.0f, output[i]); } /* |