From cb3961d9534d3bd86cc2c1c2be72b8eb33717e77 Mon Sep 17 00:00:00 2001 From: Colin Fletcher Date: Fri, 13 Feb 2015 12:25:26 +0000 Subject: [PATCH] Add a test for the constrained cubic interpolation of Evoral::Curve Add a test, based on the worked example in www.korf.co.uk/spline.pdf, for the constrained cubic spline interpolation. The delta values for the float comparisons are rather arbitrary, I'm sorry to say: they're basically chosen so that everything passes. --- libs/evoral/test/CurveTest.cpp | 180 +++++++++++++++++++++++++++++++++ libs/evoral/test/CurveTest.hpp | 2 + 2 files changed, 182 insertions(+) diff --git a/libs/evoral/test/CurveTest.cpp b/libs/evoral/test/CurveTest.cpp index 36c4d808d2..32c6fa2d64 100644 --- a/libs/evoral/test/CurveTest.cpp +++ b/libs/evoral/test/CurveTest.cpp @@ -227,3 +227,183 @@ CurveTest::ctrlListEval () CPPUNIT_ASSERT_EQUAL(8.5, cl->unlocked_eval(350.)); CPPUNIT_ASSERT_EQUAL(9.0, cl->unlocked_eval(999.)); } + +void +CurveTest::constrainedCubic () +{ + + struct point { + int x, y; + }; + + static const struct point data[] = { + /* values from worked example in www.korf.co.uk/spline.pdf */ + { 0, 30 }, + { 10, 130 }, + { 30, 150 }, + { 50, 150 }, + { 70, 170 }, + { 90, 220 }, + { 100, 320 }, + }; + + int32_t type = 0; + Evoral::Parameter p(type); + Evoral::ParameterDescriptor pd; + Evoral::ControlList l(p,pd); + + size_t i; + l.set_interpolation(Evoral::ControlList::Curved); + + for (i=0; i