From 0fd1c235de2a50524161800f90187a15fbfce735 Mon Sep 17 00:00:00 2001 From: Paul Fd Date: Mon, 6 Apr 2020 00:26:44 +0200 Subject: [PATCH] Added a basic curve test --- tests/SynthT.cpp | 14 ++++++++++++++ tests/TestFiles/curves.sfz | 10 ++++++++++ 2 files changed, 24 insertions(+) create mode 100644 tests/TestFiles/curves.sfz diff --git a/tests/SynthT.cpp b/tests/SynthT.cpp index 29b55645..6d7022ba 100644 --- a/tests/SynthT.cpp +++ b/tests/SynthT.cpp @@ -420,3 +420,17 @@ TEST_CASE("[Synth] Polyphony in master") synth.noteOn(0, 61, 64); REQUIRE(synth.getNumActiveVoices() == 3); } + +TEST_CASE("[Synth] Basic curves") +{ + sfz::Synth synth; + const auto& curves = synth.getResources().curves; + synth.loadSfzFile(fs::current_path() / "tests/TestFiles/curves.sfz"); + REQUIRE( synth.getNumCurves() == 19 ); + REQUIRE( curves.getCurve(18).evalCC7(127) == 1.0f ); + REQUIRE( curves.getCurve(18).evalCC7(95) == 0.5f ); + REQUIRE( curves.getCurve(17).evalCC7(100) == 1.0f ); + REQUIRE( curves.getCurve(17).evalCC7(95) == 0.5f ); + // Default linear + REQUIRE( curves.getCurve(16).evalCC7(63) == Approx(63_norm) ); +} diff --git a/tests/TestFiles/curves.sfz b/tests/TestFiles/curves.sfz new file mode 100644 index 00000000..8c24cca4 --- /dev/null +++ b/tests/TestFiles/curves.sfz @@ -0,0 +1,10 @@ + sample=*sine +curve_index=18 +v000=0 +v095=0.5 +v127=1 + +curve_index=17 +v000=0 +v095=0.5 +v100=1