1 #include <sigc++/sigc++.h>
17 linear.set_speed (
double(1.0)/
double(3.0));
18 linear.set_target_speed (
double(1.0)/
double(3.0));
19 result = linear.interpolate (0, 1024, input + i, output + i*3);
25 linear.set_speed (1.0);
26 linear.set_target_speed (linear.speed());
27 result = linear.interpolate (0, NUM_SAMPLES, input, output);
28 CPPUNIT_ASSERT_EQUAL ((
framecnt_t)(NUM_SAMPLES * linear.speed()), result);
30 CPPUNIT_ASSERT_EQUAL (1.0
f, output[i]);
35 linear.set_speed (0.5);
36 linear.set_target_speed (linear.speed());
37 result = linear.interpolate (0, NUM_SAMPLES, input, output);
38 CPPUNIT_ASSERT_EQUAL ((
framecnt_t)(NUM_SAMPLES * linear.speed()), result);
40 CPPUNIT_ASSERT_EQUAL (1.0
f, output[i]);
45 linear.set_speed (0.2);
46 linear.set_target_speed (linear.speed());
47 result = linear.interpolate (0, NUM_SAMPLES, input, output);
48 CPPUNIT_ASSERT_EQUAL ((
framecnt_t)(NUM_SAMPLES * linear.speed()), result);
52 linear.set_speed (0.02);
53 linear.set_target_speed (linear.speed());
54 result = linear.interpolate (0, NUM_SAMPLES, input, output);
55 CPPUNIT_ASSERT_EQUAL ((
framecnt_t)(NUM_SAMPLES * linear.speed()), result);
59 linear.set_speed (0.002);
60 linear.set_target_speed (linear.speed());
61 result = linear.interpolate (0, NUM_SAMPLES, input, output);
63 CPPUNIT_ASSERT_EQUAL ((
framecnt_t)(NUM_SAMPLES * linear.speed()), result);
67 linear.set_speed (2.0);
68 linear.set_target_speed (linear.speed());
69 result = linear.interpolate (0, NUM_SAMPLES / 2, input, output);
70 CPPUNIT_ASSERT_EQUAL ((
framecnt_t)(NUM_SAMPLES / 2 * linear.speed()), result);
71 for (
int i = 0; i < NUM_SAMPLES / 2; i += (
INTERVAL / linear.speed() +0.5)) {
72 CPPUNIT_ASSERT_EQUAL (1.0
f, output[i]);
76 linear.set_speed (10.0);
77 linear.set_target_speed (linear.speed());
78 result = linear.interpolate (0, NUM_SAMPLES / 10, input, output);
79 CPPUNIT_ASSERT_EQUAL ((
framecnt_t)(NUM_SAMPLES / 10 * linear.speed()), result);
80 for (
int i = 0; i < NUM_SAMPLES / 10; i += (
INTERVAL / linear.speed() +0.5)) {
81 CPPUNIT_ASSERT_EQUAL (1.0
f, output[i]);
98 cubic.set_speed (
double(1.0)/
double(3.0));
99 cubic.set_target_speed (
double(1.0)/
double(3.0));
100 result = cubic.interpolate (0, 1024, input + i, output + i*3);
106 cubic.set_speed (1.0);
107 cubic.set_target_speed (cubic.speed());
108 result = cubic.interpolate (0, NUM_SAMPLES, input, output);
109 CPPUNIT_ASSERT_EQUAL (result, cubic.interpolate (0, NUM_SAMPLES, NULL, NULL));
110 CPPUNIT_ASSERT_EQUAL ((
framecnt_t)(NUM_SAMPLES * cubic.speed()), result);
112 CPPUNIT_ASSERT_EQUAL (1.0
f, output[i]);
117 cubic.set_speed (0.5);
118 cubic.set_target_speed (cubic.speed());
119 result = cubic.interpolate (0, NUM_SAMPLES, input, output);
120 CPPUNIT_ASSERT_EQUAL (result, cubic.interpolate (0, NUM_SAMPLES, NULL, NULL));
121 CPPUNIT_ASSERT_EQUAL ((
framecnt_t)(NUM_SAMPLES * cubic.speed()), result);
123 CPPUNIT_ASSERT_EQUAL (1.0
f, output[i]);
128 cubic.set_speed (0.2);
129 cubic.set_target_speed (cubic.speed());
130 result = cubic.interpolate (0, NUM_SAMPLES, input, output);
131 CPPUNIT_ASSERT_EQUAL (result, cubic.interpolate (0, NUM_SAMPLES, NULL, NULL));
132 CPPUNIT_ASSERT_EQUAL ((
framecnt_t)(NUM_SAMPLES * cubic.speed()), result);
136 cubic.set_speed (0.02);
137 cubic.set_target_speed (cubic.speed());
138 result = cubic.interpolate (0, NUM_SAMPLES, input, output);
139 CPPUNIT_ASSERT_EQUAL (result, cubic.interpolate (0, NUM_SAMPLES, NULL, NULL));
140 CPPUNIT_ASSERT_EQUAL ((
framecnt_t)(NUM_SAMPLES * cubic.speed()), result);
154 cubic.set_speed (2.0);
155 cubic.set_target_speed (cubic.speed());
156 result = cubic.interpolate (0, NUM_SAMPLES / 2, input, output);
157 CPPUNIT_ASSERT_EQUAL (result, cubic.interpolate (0, NUM_SAMPLES / 2, NULL, NULL));
158 CPPUNIT_ASSERT_EQUAL ((
framecnt_t)(NUM_SAMPLES / 2 * cubic.speed()), result);
159 for (
int i = 0; i < NUM_SAMPLES / 2; i += (
INTERVAL / cubic.speed() +0.5)) {
160 CPPUNIT_ASSERT_EQUAL (1.0
f, output[i]);
164 cubic.set_speed (10.0);
165 cubic.set_target_speed (cubic.speed());
166 result = cubic.interpolate (0, NUM_SAMPLES / 10, input, output);
167 CPPUNIT_ASSERT_EQUAL (result, cubic.interpolate (0, NUM_SAMPLES / 10, NULL, NULL));
168 CPPUNIT_ASSERT_EQUAL ((
framecnt_t)(NUM_SAMPLES / 10 * cubic.speed()), result);
169 for (
int i = 0; i < NUM_SAMPLES / 10; i += (
INTERVAL / cubic.speed() +0.5)) {
170 CPPUNIT_ASSERT_EQUAL (1.0
f, output[i]);
void cubicInterpolationTest()
void linearInterpolationTest()
CPPUNIT_TEST_SUITE_REGISTRATION(InterpolationTest)