Added some tests
This commit is contained in:
parent
5fa43a0efb
commit
32d01ded03
1 changed files with 106 additions and 0 deletions
|
|
@ -15,3 +15,109 @@ TEST_CASE("[Tuning] Default tuning")
|
|||
for (int key = 0; key < 128; ++key)
|
||||
REQUIRE(defaultTuning.getFrequencyOfKey(key) == Approx(midiNoteFrequency(key)));
|
||||
}
|
||||
|
||||
TEST_CASE("[Tuning] Railsback disabled")
|
||||
{
|
||||
auto tuning = sfz::StretchTuning::createRailsbackFromRatio(0.0f);
|
||||
for (int key = 0; key < 128; ++key)
|
||||
REQUIRE(tuning.getRatioForIntegralKey(key) == 1.0f);
|
||||
}
|
||||
|
||||
TEST_CASE("[Tuning] Stretch integral == float")
|
||||
{
|
||||
auto tuning = sfz::StretchTuning::createRailsbackFromRatio(0.25f);
|
||||
for (int key = 0; key < 128; ++key)
|
||||
REQUIRE(tuning.getRatioForIntegralKey(key) == tuning.getRatioForFractionalKey(static_cast<float>(key)));
|
||||
}
|
||||
|
||||
TEST_CASE("[Tuning] Stretch definition points")
|
||||
{
|
||||
SECTION("For 0.5f")
|
||||
{
|
||||
static constexpr float railsback[128] = {
|
||||
#include "sfizz/railsback/4-1.h"
|
||||
};
|
||||
auto tuning = sfz::StretchTuning::createRailsbackFromRatio(0.5f);
|
||||
for (int key = 0; key < 128; ++key)
|
||||
REQUIRE(tuning.getRatioForIntegralKey(key) == railsback[key]);
|
||||
}
|
||||
SECTION("For 1.0f")
|
||||
{
|
||||
static constexpr float railsback[128] = {
|
||||
#include "sfizz/railsback/4-2.h"
|
||||
};
|
||||
auto tuning = sfz::StretchTuning::createRailsbackFromRatio(1.0f);
|
||||
for (int key = 0; key < 128; ++key)
|
||||
REQUIRE(tuning.getRatioForIntegralKey(key) == railsback[key]);
|
||||
}
|
||||
|
||||
SECTION("For 0.25f")
|
||||
{
|
||||
static constexpr float railsback[128] = {
|
||||
#include "sfizz/railsback/2-1.h"
|
||||
};
|
||||
auto tuning = sfz::StretchTuning::createRailsbackFromRatio(0.25f);
|
||||
for (int key = 0; key < 128; ++key)
|
||||
REQUIRE(tuning.getRatioForIntegralKey(key) == railsback[key]);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("[Tuning] Stretch interpolation bounds")
|
||||
{
|
||||
SECTION("Between 0 and 0.25f")
|
||||
{
|
||||
static constexpr float bound1[128] = {
|
||||
#include "sfizz/railsback/2-1.h"
|
||||
};
|
||||
auto tuning = sfz::StretchTuning::createRailsbackFromRatio(0.1f);
|
||||
for (int key = 0; key < 128; ++key) {
|
||||
if (bound1[key] < 1.0f) {
|
||||
REQUIRE(tuning.getRatioForIntegralKey(key) >= bound1[key]);
|
||||
REQUIRE(tuning.getRatioForIntegralKey(key) <= 1.0f);
|
||||
} else {
|
||||
REQUIRE(tuning.getRatioForIntegralKey(key) <= bound1[key]);
|
||||
REQUIRE(tuning.getRatioForIntegralKey(key) >= 1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
SECTION("Between 0.25f and 0.5f")
|
||||
{
|
||||
static constexpr float bound1[128] = {
|
||||
#include "sfizz/railsback/2-1.h"
|
||||
};
|
||||
static constexpr float bound2[128] = {
|
||||
#include "sfizz/railsback/4-1.h"
|
||||
};
|
||||
auto tuning = sfz::StretchTuning::createRailsbackFromRatio(0.3f);
|
||||
for (int key = 0; key < 128; ++key) {
|
||||
if (bound1[key] < bound2[key]) {
|
||||
REQUIRE(tuning.getRatioForIntegralKey(key) >= bound1[key]);
|
||||
REQUIRE(tuning.getRatioForIntegralKey(key) <= bound2[key]);
|
||||
} else {
|
||||
REQUIRE(tuning.getRatioForIntegralKey(key) <= bound1[key]);
|
||||
REQUIRE(tuning.getRatioForIntegralKey(key) >= bound2[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
SECTION("Between 0.5f and 1.0f")
|
||||
{
|
||||
static constexpr float bound1[128] = {
|
||||
#include "sfizz/railsback/4-1.h"
|
||||
};
|
||||
static constexpr float bound2[128] = {
|
||||
#include "sfizz/railsback/4-2.h"
|
||||
};
|
||||
auto tuning = sfz::StretchTuning::createRailsbackFromRatio(0.7f);
|
||||
for (int key = 0; key < 128; ++key) {
|
||||
if (bound1[key] < bound2[key]) {
|
||||
REQUIRE(tuning.getRatioForIntegralKey(key) >= bound1[key]);
|
||||
REQUIRE(tuning.getRatioForIntegralKey(key) <= bound2[key]);
|
||||
} else {
|
||||
REQUIRE(tuning.getRatioForIntegralKey(key) <= bound1[key]);
|
||||
REQUIRE(tuning.getRatioForIntegralKey(key) >= bound2[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue