Refactor the float versions
This commit is contained in:
parent
7ed7720a54
commit
c4db2bba56
7 changed files with 221 additions and 221 deletions
|
|
@ -805,7 +805,7 @@ bool sfz::Region::isSwitchedOn() const noexcept
|
|||
return keySwitched && previousKeySwitched && sequenceSwitched && pitchSwitched && bpmSwitched && aftertouchSwitched && ccSwitched.all();
|
||||
}
|
||||
|
||||
bool sfz::Region::registerNoteOnNormalized(int noteNumber, float velocity, float randValue) noexcept
|
||||
bool sfz::Region::registerNoteOn(int noteNumber, float velocity, float randValue) noexcept
|
||||
{
|
||||
ASSERT(velocity >= 0.0f && velocity <= 1.0f);
|
||||
|
||||
|
|
@ -859,7 +859,7 @@ bool sfz::Region::registerNoteOnNormalized(int noteNumber, float velocity, float
|
|||
return keyOk && velOk && randOk && (attackTrigger || firstLegatoNote || notFirstLegatoNote);
|
||||
}
|
||||
|
||||
bool sfz::Region::registerNoteOffNormalized(int noteNumber, float velocity, float randValue) noexcept
|
||||
bool sfz::Region::registerNoteOff(int noteNumber, float velocity, float randValue) noexcept
|
||||
{
|
||||
ASSERT(velocity >= 0.0f && velocity <= 1.0f);
|
||||
|
||||
|
|
@ -885,7 +885,7 @@ bool sfz::Region::registerNoteOffNormalized(int noteNumber, float velocity, floa
|
|||
return keyOk && velOk && randOk && releaseTrigger;
|
||||
}
|
||||
|
||||
bool sfz::Region::registerCCNormalized(int ccNumber, float ccValue) noexcept
|
||||
bool sfz::Region::registerCC(int ccNumber, float ccValue) noexcept
|
||||
{
|
||||
ASSERT(ccValue >= 0.0f && ccValue <= 1.0f);
|
||||
if (ccConditions.getWithDefault(ccNumber).containsWithEnd(ccValue))
|
||||
|
|
@ -930,7 +930,7 @@ void sfz::Region::registerTempo(float secondsPerQuarter) noexcept
|
|||
bpmSwitched = false;
|
||||
}
|
||||
|
||||
float sfz::Region::getBasePitchVariationNormalized(int noteNumber, float velocity) const noexcept
|
||||
float sfz::Region::getBasePitchVariation(int noteNumber, float velocity) const noexcept
|
||||
{
|
||||
ASSERT(velocity >= 0.0f && velocity <= 1.0f);
|
||||
|
||||
|
|
@ -1039,7 +1039,7 @@ float crossfadeOut(const sfz::Range<T>& crossfadeRange, U value, SfzCrossfadeCur
|
|||
return 1.0f;
|
||||
}
|
||||
|
||||
float sfz::Region::getNoteGainNormalized(int noteNumber, float velocity) const noexcept
|
||||
float sfz::Region::getNoteGain(int noteNumber, float velocity) const noexcept
|
||||
{
|
||||
ASSERT(velocity >= 0.0f && velocity <= 1.0f);
|
||||
|
||||
|
|
@ -1053,7 +1053,7 @@ float sfz::Region::getNoteGainNormalized(int noteNumber, float velocity) const n
|
|||
baseGain *= crossfadeOut(crossfadeKeyOutRange, noteNumber, crossfadeKeyCurve);
|
||||
|
||||
// Amplitude velocity tracking
|
||||
baseGain *= velocityCurveNormalized(velocity);
|
||||
baseGain *= velocityCurve(velocity);
|
||||
|
||||
// Crossfades related to velocity
|
||||
baseGain *= crossfadeIn(crossfadeVelInRange, velocity, crossfadeVelCurve);
|
||||
|
|
@ -1082,7 +1082,7 @@ float sfz::Region::getCrossfadeGain() const noexcept
|
|||
return gain;
|
||||
}
|
||||
|
||||
float sfz::Region::velocityCurveNormalized(float velocity) const noexcept
|
||||
float sfz::Region::velocityCurve(float velocity) const noexcept
|
||||
{
|
||||
ASSERT(velocity >= 0.0f && velocity <= 1.0f);
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ struct Region {
|
|||
* @return true if the region should trigger on this event.
|
||||
* @return false
|
||||
*/
|
||||
bool registerNoteOnNormalized(int noteNumber, float velocity, float randValue) noexcept;
|
||||
bool registerNoteOn(int noteNumber, float velocity, float randValue) noexcept;
|
||||
/**
|
||||
* @brief Register a new note off event. The region may be switched on or off using keys so
|
||||
* this function updates the keyswitches state.
|
||||
|
|
@ -97,7 +97,7 @@ struct Region {
|
|||
* @return true if the region should trigger on this event.
|
||||
* @return false
|
||||
*/
|
||||
bool registerNoteOffNormalized(int noteNumber, float velocity, float randValue) noexcept;
|
||||
bool registerNoteOff(int noteNumber, float velocity, float randValue) noexcept;
|
||||
/**
|
||||
* @brief Register a new CC event. The region may be switched on or off using CCs so
|
||||
* this function checks if it indeeds need to activate or not.
|
||||
|
|
@ -107,7 +107,7 @@ struct Region {
|
|||
* @return true if the region should trigger on this event
|
||||
* @return false
|
||||
*/
|
||||
bool registerCCNormalized(int ccNumber, float ccValue) noexcept;
|
||||
bool registerCC(int ccNumber, float ccValue) noexcept;
|
||||
/**
|
||||
* @brief Register a new pitch wheel event.
|
||||
*
|
||||
|
|
@ -135,7 +135,7 @@ struct Region {
|
|||
* @param velocity
|
||||
* @return float
|
||||
*/
|
||||
float getBasePitchVariationNormalized(int noteNumber, float velocity) const noexcept;
|
||||
float getBasePitchVariation(int noteNumber, float velocity) const noexcept;
|
||||
/**
|
||||
* @brief Get the note-related gain of the region depending on which note has been
|
||||
* pressed and at which velocity.
|
||||
|
|
@ -144,7 +144,7 @@ struct Region {
|
|||
* @param velocity
|
||||
* @return float
|
||||
*/
|
||||
float getNoteGainNormalized(int noteNumber, float velocity) const noexcept;
|
||||
float getNoteGain(int noteNumber, float velocity) const noexcept;
|
||||
/**
|
||||
* @brief Get the additional crossfade gain of the region depending on the
|
||||
* CC values
|
||||
|
|
@ -178,7 +178,7 @@ struct Region {
|
|||
*
|
||||
* @return float
|
||||
*/
|
||||
float velocityCurveNormalized(float velocity) const noexcept;
|
||||
float velocityCurve(float velocity) const noexcept;
|
||||
/**
|
||||
* @brief Get the region offset in samples
|
||||
*
|
||||
|
|
|
|||
|
|
@ -387,12 +387,12 @@ bool sfz::Synth::loadSfzFile(const fs::path& file)
|
|||
|
||||
// Defaults
|
||||
for (unsigned cc = 0; cc < config::numCCs; cc++) {
|
||||
region->registerCCNormalized(cc, resources.midiState.getCCValueNormalized(cc));
|
||||
region->registerCC(cc, resources.midiState.getCCValueNormalized(cc));
|
||||
}
|
||||
|
||||
if (defaultSwitch) {
|
||||
region->registerNoteOnNormalized(*defaultSwitch, 1.0f, 1.0f);
|
||||
region->registerNoteOffNormalized(*defaultSwitch, 0.0f, 1.0f);
|
||||
region->registerNoteOn(*defaultSwitch, 1.0f, 1.0f);
|
||||
region->registerNoteOff(*defaultSwitch, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
// Set the default frequencies on equalizers if needed
|
||||
|
|
@ -640,7 +640,7 @@ void sfz::Synth::noteOffDispatch(int delay, int noteNumber, float velocity) noex
|
|||
{
|
||||
const auto randValue = randNoteDistribution(Random::randomGenerator);
|
||||
for (auto& region : noteActivationLists[noteNumber]) {
|
||||
if (region->registerNoteOffNormalized(noteNumber, velocity, randValue)) {
|
||||
if (region->registerNoteOff(noteNumber, velocity, randValue)) {
|
||||
auto voice = findFreeVoice();
|
||||
if (voice == nullptr)
|
||||
continue;
|
||||
|
|
@ -654,7 +654,7 @@ void sfz::Synth::noteOnDispatch(int delay, int noteNumber, float velocity) noexc
|
|||
{
|
||||
const auto randValue = randNoteDistribution(Random::randomGenerator);
|
||||
for (auto& region : noteActivationLists[noteNumber]) {
|
||||
if (region->registerNoteOnNormalized(noteNumber, velocity, randValue)) {
|
||||
if (region->registerNoteOn(noteNumber, velocity, randValue)) {
|
||||
for (auto& voice : voices) {
|
||||
if (voice->checkOffGroup(delay, region->group))
|
||||
noteOffDispatch(delay, voice->getTriggerNumber(), voice->getTriggerValue());
|
||||
|
|
@ -691,7 +691,7 @@ void sfz::Synth::cc(int delay, int ccNumber, uint8_t ccValue) noexcept
|
|||
voice->registerCC(delay, ccNumber, normalizedCC);
|
||||
|
||||
for (auto& region : ccActivationLists[ccNumber]) {
|
||||
if (region->registerCCNormalized(ccNumber, normalizedCC)) {
|
||||
if (region->registerCC(ccNumber, normalizedCC)) {
|
||||
auto voice = findFreeVoice();
|
||||
if (voice == nullptr)
|
||||
continue;
|
||||
|
|
@ -959,7 +959,7 @@ void sfz::Synth::resetAllControllers(int delay) noexcept
|
|||
|
||||
for (auto& region : regions) {
|
||||
for (unsigned cc = 0; cc < config::numCCs; ++cc)
|
||||
region->registerCCNormalized(cc, 0.0f);
|
||||
region->registerCC(cc, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ void sfz::Voice::startVoice(Region* region, int delay, int number, float value,
|
|||
}
|
||||
speedRatio = static_cast<float>(currentPromise->sampleRate / this->sampleRate);
|
||||
}
|
||||
pitchRatio = region->getBasePitchVariationNormalized(number, value);
|
||||
pitchRatio = region->getBasePitchVariation(number, value);
|
||||
|
||||
baseVolumedB = region->getBaseVolumedB(number);
|
||||
auto volumedB = baseVolumedB;
|
||||
|
|
@ -83,7 +83,7 @@ void sfz::Voice::startVoice(Region* region, int delay, int number, float value,
|
|||
|
||||
baseGain = region->getBaseGain();
|
||||
if (triggerType != TriggerType::CC)
|
||||
baseGain *= region->getNoteGainNormalized(number, value);
|
||||
baseGain *= region->getNoteGain(number, value);
|
||||
|
||||
float gain { baseGain };
|
||||
if (region->amplitudeCC)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ TEST_CASE("Region activation", "Region tests")
|
|||
region.parseOpcode({ "sample", "*sine" });
|
||||
SECTION("Basic state")
|
||||
{
|
||||
region.registerCCNormalized(4, 0_norm);
|
||||
region.registerCC(4, 0_norm);
|
||||
REQUIRE(region.isSwitchedOn());
|
||||
}
|
||||
|
||||
|
|
@ -26,19 +26,19 @@ TEST_CASE("Region activation", "Region tests")
|
|||
{
|
||||
region.parseOpcode({ "locc4", "56" });
|
||||
region.parseOpcode({ "hicc4", "59" });
|
||||
region.registerCCNormalized(4, 0_norm);
|
||||
region.registerCC(4, 0_norm);
|
||||
REQUIRE(!region.isSwitchedOn());
|
||||
region.registerCCNormalized(4, 57_norm);
|
||||
region.registerCC(4, 57_norm);
|
||||
REQUIRE(region.isSwitchedOn());
|
||||
region.registerCCNormalized(4, 56_norm);
|
||||
region.registerCC(4, 56_norm);
|
||||
REQUIRE(region.isSwitchedOn());
|
||||
region.registerCCNormalized(4, 59_norm);
|
||||
region.registerCC(4, 59_norm);
|
||||
REQUIRE(region.isSwitchedOn());
|
||||
region.registerCCNormalized(4, 43_norm);
|
||||
region.registerCC(4, 43_norm);
|
||||
REQUIRE(!region.isSwitchedOn());
|
||||
region.registerCCNormalized(4, 65_norm);
|
||||
region.registerCC(4, 65_norm);
|
||||
REQUIRE(!region.isSwitchedOn());
|
||||
region.registerCCNormalized(6, 57_norm);
|
||||
region.registerCC(6, 57_norm);
|
||||
REQUIRE(!region.isSwitchedOn());
|
||||
}
|
||||
|
||||
|
|
@ -48,26 +48,26 @@ TEST_CASE("Region activation", "Region tests")
|
|||
region.parseOpcode({ "hicc4", "59" });
|
||||
region.parseOpcode({ "locc54", "18" });
|
||||
region.parseOpcode({ "hicc54", "27" });
|
||||
region.registerCCNormalized(4, 0_norm);
|
||||
region.registerCCNormalized(54, 0_norm);
|
||||
region.registerCC(4, 0_norm);
|
||||
region.registerCC(54, 0_norm);
|
||||
REQUIRE(!region.isSwitchedOn());
|
||||
region.registerCCNormalized(4, 57_norm);
|
||||
region.registerCC(4, 57_norm);
|
||||
REQUIRE(!region.isSwitchedOn());
|
||||
region.registerCCNormalized(54, 19_norm);
|
||||
region.registerCC(54, 19_norm);
|
||||
REQUIRE(region.isSwitchedOn());
|
||||
region.registerCCNormalized(54, 18_norm);
|
||||
region.registerCC(54, 18_norm);
|
||||
REQUIRE(region.isSwitchedOn());
|
||||
region.registerCCNormalized(54, 27_norm);
|
||||
region.registerCC(54, 27_norm);
|
||||
REQUIRE(region.isSwitchedOn());
|
||||
region.registerCCNormalized(4, 56_norm);
|
||||
region.registerCC(4, 56_norm);
|
||||
REQUIRE(region.isSwitchedOn());
|
||||
region.registerCCNormalized(4, 59_norm);
|
||||
region.registerCC(4, 59_norm);
|
||||
REQUIRE(region.isSwitchedOn());
|
||||
region.registerCCNormalized(54, 2_norm);
|
||||
region.registerCC(54, 2_norm);
|
||||
REQUIRE(!region.isSwitchedOn());
|
||||
region.registerCCNormalized(54, 26_norm);
|
||||
region.registerCC(54, 26_norm);
|
||||
REQUIRE(region.isSwitchedOn());
|
||||
region.registerCCNormalized(4, 65_norm);
|
||||
region.registerCC(4, 65_norm);
|
||||
REQUIRE(!region.isSwitchedOn());
|
||||
}
|
||||
|
||||
|
|
@ -118,13 +118,13 @@ TEST_CASE("Region activation", "Region tests")
|
|||
{
|
||||
region.parseOpcode({ "sw_last", "40" });
|
||||
REQUIRE(!region.isSwitchedOn());
|
||||
region.registerNoteOnNormalized(40, 64_norm, 0.5f);
|
||||
region.registerNoteOn(40, 64_norm, 0.5f);
|
||||
REQUIRE(region.isSwitchedOn());
|
||||
region.registerNoteOffNormalized(40, 64_norm, 0.5f);
|
||||
region.registerNoteOff(40, 64_norm, 0.5f);
|
||||
REQUIRE(region.isSwitchedOn());
|
||||
region.registerNoteOnNormalized(41, 64_norm, 0.5f);
|
||||
region.registerNoteOn(41, 64_norm, 0.5f);
|
||||
REQUIRE(!region.isSwitchedOn());
|
||||
region.registerNoteOffNormalized(41, 0_norm, 0.5f);
|
||||
region.registerNoteOff(41, 0_norm, 0.5f);
|
||||
}
|
||||
|
||||
SECTION("Keyswitches: sw_last with non-default keyswitch range")
|
||||
|
|
@ -133,20 +133,20 @@ TEST_CASE("Region activation", "Region tests")
|
|||
region.parseOpcode({ "sw_hikey", "50" });
|
||||
region.parseOpcode({ "sw_last", "40" });
|
||||
REQUIRE(!region.isSwitchedOn());
|
||||
region.registerNoteOnNormalized(60, 64_norm, 0.5f);
|
||||
region.registerNoteOn(60, 64_norm, 0.5f);
|
||||
REQUIRE(!region.isSwitchedOn());
|
||||
region.registerNoteOffNormalized(60, 0_norm, 0.5f);
|
||||
region.registerNoteOff(60, 0_norm, 0.5f);
|
||||
REQUIRE(!region.isSwitchedOn());
|
||||
region.registerNoteOnNormalized(40, 64_norm, 0.5f);
|
||||
region.registerNoteOn(40, 64_norm, 0.5f);
|
||||
REQUIRE(region.isSwitchedOn());
|
||||
region.registerNoteOffNormalized(40, 0_norm, 0.5f);
|
||||
region.registerNoteOff(40, 0_norm, 0.5f);
|
||||
REQUIRE(region.isSwitchedOn());
|
||||
region.registerNoteOnNormalized(60, 64_norm, 0.5f);
|
||||
region.registerNoteOn(60, 64_norm, 0.5f);
|
||||
REQUIRE(region.isSwitchedOn());
|
||||
region.registerNoteOffNormalized(60, 0_norm, 0.5f);
|
||||
region.registerNoteOnNormalized(41, 64_norm, 0.5f);
|
||||
region.registerNoteOff(60, 0_norm, 0.5f);
|
||||
region.registerNoteOn(41, 64_norm, 0.5f);
|
||||
REQUIRE(!region.isSwitchedOn());
|
||||
region.registerNoteOffNormalized(41, 0_norm, 0.5f);
|
||||
region.registerNoteOff(41, 0_norm, 0.5f);
|
||||
}
|
||||
|
||||
SECTION("Keyswitches: sw_down with non-default keyswitch range")
|
||||
|
|
@ -155,20 +155,20 @@ TEST_CASE("Region activation", "Region tests")
|
|||
region.parseOpcode({ "sw_hikey", "50" });
|
||||
region.parseOpcode({ "sw_down", "40" });
|
||||
REQUIRE(!region.isSwitchedOn());
|
||||
region.registerNoteOnNormalized(60, 64_norm, 0.5f);
|
||||
region.registerNoteOn(60, 64_norm, 0.5f);
|
||||
REQUIRE(!region.isSwitchedOn());
|
||||
region.registerNoteOffNormalized(60, 0_norm, 0.5f);
|
||||
region.registerNoteOff(60, 0_norm, 0.5f);
|
||||
REQUIRE(!region.isSwitchedOn());
|
||||
region.registerNoteOnNormalized(40, 64_norm, 0.5f);
|
||||
region.registerNoteOn(40, 64_norm, 0.5f);
|
||||
REQUIRE(region.isSwitchedOn());
|
||||
region.registerNoteOffNormalized(40, 0_norm, 0.5f);
|
||||
region.registerNoteOff(40, 0_norm, 0.5f);
|
||||
REQUIRE(!region.isSwitchedOn());
|
||||
region.registerNoteOnNormalized(60, 64_norm, 0.5f);
|
||||
region.registerNoteOn(60, 64_norm, 0.5f);
|
||||
REQUIRE(!region.isSwitchedOn());
|
||||
region.registerNoteOffNormalized(60, 0_norm, 0.5f);
|
||||
region.registerNoteOnNormalized(41, 64_norm, 0.5f);
|
||||
region.registerNoteOff(60, 0_norm, 0.5f);
|
||||
region.registerNoteOn(41, 64_norm, 0.5f);
|
||||
REQUIRE(!region.isSwitchedOn());
|
||||
region.registerNoteOffNormalized(41, 0_norm, 0.5f);
|
||||
region.registerNoteOff(41, 0_norm, 0.5f);
|
||||
}
|
||||
|
||||
SECTION("Keyswitches: sw_up with non-default keyswitch range")
|
||||
|
|
@ -177,16 +177,16 @@ TEST_CASE("Region activation", "Region tests")
|
|||
region.parseOpcode({ "sw_hikey", "50" });
|
||||
region.parseOpcode({ "sw_up", "40" });
|
||||
REQUIRE(region.isSwitchedOn());
|
||||
region.registerNoteOnNormalized(40, 64_norm, 0.5f);
|
||||
region.registerNoteOn(40, 64_norm, 0.5f);
|
||||
REQUIRE(!region.isSwitchedOn());
|
||||
region.registerNoteOffNormalized(40, 0_norm, 0.5f);
|
||||
region.registerNoteOff(40, 0_norm, 0.5f);
|
||||
REQUIRE(region.isSwitchedOn());
|
||||
region.registerNoteOnNormalized(41, 64_norm, 0.5f);
|
||||
region.registerNoteOn(41, 64_norm, 0.5f);
|
||||
REQUIRE(region.isSwitchedOn());
|
||||
region.registerNoteOnNormalized(40, 64_norm, 0.5f);
|
||||
region.registerNoteOn(40, 64_norm, 0.5f);
|
||||
REQUIRE(!region.isSwitchedOn());
|
||||
region.registerNoteOffNormalized(40, 0_norm, 0.5f);
|
||||
region.registerNoteOffNormalized(41, 0_norm, 0.5f);
|
||||
region.registerNoteOff(40, 0_norm, 0.5f);
|
||||
region.registerNoteOff(41, 0_norm, 0.5f);
|
||||
REQUIRE(region.isSwitchedOn());
|
||||
}
|
||||
|
||||
|
|
@ -194,20 +194,20 @@ TEST_CASE("Region activation", "Region tests")
|
|||
{
|
||||
region.parseOpcode({ "sw_previous", "40" });
|
||||
REQUIRE(!region.isSwitchedOn());
|
||||
region.registerNoteOnNormalized(40, 64_norm, 0.5f);
|
||||
region.registerNoteOn(40, 64_norm, 0.5f);
|
||||
REQUIRE(region.isSwitchedOn());
|
||||
region.registerNoteOffNormalized(40, 0_norm, 0.5f);
|
||||
region.registerNoteOff(40, 0_norm, 0.5f);
|
||||
REQUIRE(region.isSwitchedOn());
|
||||
region.registerNoteOnNormalized(41, 64_norm, 0.5f);
|
||||
region.registerNoteOn(41, 64_norm, 0.5f);
|
||||
REQUIRE(!region.isSwitchedOn());
|
||||
region.registerNoteOnNormalized(40, 64_norm, 0.5f);
|
||||
region.registerNoteOn(40, 64_norm, 0.5f);
|
||||
REQUIRE(region.isSwitchedOn());
|
||||
region.registerNoteOffNormalized(40, 0_norm, 0.5f);
|
||||
region.registerNoteOffNormalized(41, 0_norm, 0.5f);
|
||||
region.registerNoteOff(40, 0_norm, 0.5f);
|
||||
region.registerNoteOff(41, 0_norm, 0.5f);
|
||||
REQUIRE(region.isSwitchedOn());
|
||||
region.registerNoteOnNormalized(41, 64_norm, 0.5f);
|
||||
region.registerNoteOn(41, 64_norm, 0.5f);
|
||||
REQUIRE(!region.isSwitchedOn());
|
||||
region.registerNoteOffNormalized(41, 0_norm, 0.5f);
|
||||
region.registerNoteOff(41, 0_norm, 0.5f);
|
||||
REQUIRE(!region.isSwitchedOn());
|
||||
}
|
||||
|
||||
|
|
@ -217,17 +217,17 @@ TEST_CASE("Region activation", "Region tests")
|
|||
region.parseOpcode({ "seq_position", "1" });
|
||||
region.parseOpcode({ "key", "40" });
|
||||
REQUIRE(region.isSwitchedOn());
|
||||
region.registerNoteOnNormalized(40, 64_norm, 0.5f);
|
||||
region.registerNoteOn(40, 64_norm, 0.5f);
|
||||
REQUIRE(!region.isSwitchedOn());
|
||||
region.registerNoteOffNormalized(40, 0_norm, 0.5f);
|
||||
region.registerNoteOff(40, 0_norm, 0.5f);
|
||||
REQUIRE(!region.isSwitchedOn());
|
||||
region.registerNoteOnNormalized(40, 64_norm, 0.5f);
|
||||
region.registerNoteOn(40, 64_norm, 0.5f);
|
||||
REQUIRE(region.isSwitchedOn());
|
||||
region.registerNoteOffNormalized(40, 0_norm, 0.5f);
|
||||
region.registerNoteOff(40, 0_norm, 0.5f);
|
||||
REQUIRE(region.isSwitchedOn());
|
||||
region.registerNoteOnNormalized(40, 64_norm, 0.5f);
|
||||
region.registerNoteOn(40, 64_norm, 0.5f);
|
||||
REQUIRE(!region.isSwitchedOn());
|
||||
region.registerNoteOffNormalized(40, 0_norm, 0.5f);
|
||||
region.registerNoteOff(40, 0_norm, 0.5f);
|
||||
REQUIRE(!region.isSwitchedOn());
|
||||
}
|
||||
SECTION("Sequences: length 2, position 2")
|
||||
|
|
@ -236,17 +236,17 @@ TEST_CASE("Region activation", "Region tests")
|
|||
region.parseOpcode({ "seq_position", "2" });
|
||||
region.parseOpcode({ "key", "40" });
|
||||
REQUIRE(!region.isSwitchedOn());
|
||||
region.registerNoteOnNormalized(40, 64_norm, 0.5f);
|
||||
region.registerNoteOn(40, 64_norm, 0.5f);
|
||||
REQUIRE(region.isSwitchedOn());
|
||||
region.registerNoteOffNormalized(40, 0_norm, 0.5f);
|
||||
region.registerNoteOff(40, 0_norm, 0.5f);
|
||||
REQUIRE(region.isSwitchedOn());
|
||||
region.registerNoteOnNormalized(40, 64_norm, 0.5f);
|
||||
region.registerNoteOn(40, 64_norm, 0.5f);
|
||||
REQUIRE(!region.isSwitchedOn());
|
||||
region.registerNoteOffNormalized(40, 0_norm, 0.5f);
|
||||
region.registerNoteOff(40, 0_norm, 0.5f);
|
||||
REQUIRE(!region.isSwitchedOn());
|
||||
region.registerNoteOnNormalized(40, 64_norm, 0.5f);
|
||||
region.registerNoteOn(40, 64_norm, 0.5f);
|
||||
REQUIRE(region.isSwitchedOn());
|
||||
region.registerNoteOffNormalized(40, 0_norm, 0.5f);
|
||||
region.registerNoteOff(40, 0_norm, 0.5f);
|
||||
REQUIRE(region.isSwitchedOn());
|
||||
}
|
||||
SECTION("Sequences: length 3, position 2")
|
||||
|
|
@ -255,21 +255,21 @@ TEST_CASE("Region activation", "Region tests")
|
|||
region.parseOpcode({ "seq_position", "2" });
|
||||
region.parseOpcode({ "key", "40" });
|
||||
REQUIRE(!region.isSwitchedOn());
|
||||
region.registerNoteOnNormalized(40, 64_norm, 0.5f);
|
||||
region.registerNoteOn(40, 64_norm, 0.5f);
|
||||
REQUIRE(region.isSwitchedOn());
|
||||
region.registerNoteOffNormalized(40, 0_norm, 0.5f);
|
||||
region.registerNoteOff(40, 0_norm, 0.5f);
|
||||
REQUIRE(region.isSwitchedOn());
|
||||
region.registerNoteOnNormalized(40, 64_norm, 0.5f);
|
||||
region.registerNoteOn(40, 64_norm, 0.5f);
|
||||
REQUIRE(!region.isSwitchedOn());
|
||||
region.registerNoteOffNormalized(40, 0_norm, 0.5f);
|
||||
region.registerNoteOff(40, 0_norm, 0.5f);
|
||||
REQUIRE(!region.isSwitchedOn());
|
||||
region.registerNoteOnNormalized(40, 64_norm, 0.5f);
|
||||
region.registerNoteOn(40, 64_norm, 0.5f);
|
||||
REQUIRE(!region.isSwitchedOn());
|
||||
region.registerNoteOffNormalized(40, 0_norm, 0.5f);
|
||||
region.registerNoteOff(40, 0_norm, 0.5f);
|
||||
REQUIRE(!region.isSwitchedOn());
|
||||
region.registerNoteOnNormalized(40, 64_norm, 0.5f);
|
||||
region.registerNoteOn(40, 64_norm, 0.5f);
|
||||
REQUIRE(region.isSwitchedOn());
|
||||
region.registerNoteOffNormalized(40, 0_norm, 0.5f);
|
||||
region.registerNoteOff(40, 0_norm, 0.5f);
|
||||
REQUIRE(region.isSwitchedOn());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,44 +19,44 @@ TEST_CASE("Basic triggers", "Region triggers")
|
|||
SECTION("key")
|
||||
{
|
||||
region.parseOpcode({ "key", "40" });
|
||||
REQUIRE(region.registerNoteOnNormalized(40, 64_norm, 0.5f));
|
||||
REQUIRE(!region.registerNoteOffNormalized(40, 64_norm, 0.5f));
|
||||
REQUIRE(!region.registerNoteOnNormalized(41, 64_norm, 0.5f));
|
||||
REQUIRE(!region.registerCCNormalized(63, 64_norm));
|
||||
REQUIRE(region.registerNoteOn(40, 64_norm, 0.5f));
|
||||
REQUIRE(!region.registerNoteOff(40, 64_norm, 0.5f));
|
||||
REQUIRE(!region.registerNoteOn(41, 64_norm, 0.5f));
|
||||
REQUIRE(!region.registerCC(63, 64_norm));
|
||||
}
|
||||
SECTION("lokey and hikey")
|
||||
{
|
||||
region.parseOpcode({ "lokey", "40" });
|
||||
region.parseOpcode({ "hikey", "42" });
|
||||
REQUIRE(!region.registerNoteOnNormalized(39, 64_norm, 0.5f));
|
||||
REQUIRE(region.registerNoteOnNormalized(40, 64_norm, 0.5f));
|
||||
REQUIRE(!region.registerNoteOffNormalized(40, 64_norm, 0.5f));
|
||||
REQUIRE(region.registerNoteOnNormalized(41, 64_norm, 0.5f));
|
||||
REQUIRE(region.registerNoteOnNormalized(42, 64_norm, 0.5f));
|
||||
REQUIRE(!region.registerNoteOnNormalized(43, 64_norm, 0.5f));
|
||||
REQUIRE(!region.registerNoteOffNormalized(42, 64_norm, 0.5f));
|
||||
REQUIRE(!region.registerNoteOffNormalized(42, 64_norm, 0.5f));
|
||||
REQUIRE(!region.registerCCNormalized(63, 64_norm));
|
||||
REQUIRE(!region.registerNoteOn(39, 64_norm, 0.5f));
|
||||
REQUIRE(region.registerNoteOn(40, 64_norm, 0.5f));
|
||||
REQUIRE(!region.registerNoteOff(40, 64_norm, 0.5f));
|
||||
REQUIRE(region.registerNoteOn(41, 64_norm, 0.5f));
|
||||
REQUIRE(region.registerNoteOn(42, 64_norm, 0.5f));
|
||||
REQUIRE(!region.registerNoteOn(43, 64_norm, 0.5f));
|
||||
REQUIRE(!region.registerNoteOff(42, 64_norm, 0.5f));
|
||||
REQUIRE(!region.registerNoteOff(42, 64_norm, 0.5f));
|
||||
REQUIRE(!region.registerCC(63, 64_norm));
|
||||
}
|
||||
SECTION("key and release trigger")
|
||||
{
|
||||
region.parseOpcode({ "key", "40" });
|
||||
region.parseOpcode({ "trigger", "release" });
|
||||
REQUIRE(!region.registerNoteOnNormalized(40, 64_norm, 0.5f));
|
||||
REQUIRE(region.registerNoteOffNormalized(40, 64_norm, 0.5f));
|
||||
REQUIRE(!region.registerNoteOnNormalized(41, 64_norm, 0.5f));
|
||||
REQUIRE(!region.registerNoteOffNormalized(41, 64_norm, 0.5f));
|
||||
REQUIRE(!region.registerCCNormalized(63, 64_norm));
|
||||
REQUIRE(!region.registerNoteOn(40, 64_norm, 0.5f));
|
||||
REQUIRE(region.registerNoteOff(40, 64_norm, 0.5f));
|
||||
REQUIRE(!region.registerNoteOn(41, 64_norm, 0.5f));
|
||||
REQUIRE(!region.registerNoteOff(41, 64_norm, 0.5f));
|
||||
REQUIRE(!region.registerCC(63, 64_norm));
|
||||
}
|
||||
SECTION("key and release_key trigger")
|
||||
{
|
||||
region.parseOpcode({ "key", "40" });
|
||||
region.parseOpcode({ "trigger", "release_key" });
|
||||
REQUIRE(!region.registerNoteOnNormalized(40, 64_norm, 0.5f));
|
||||
REQUIRE(region.registerNoteOffNormalized(40, 64_norm, 0.5f));
|
||||
REQUIRE(!region.registerNoteOnNormalized(41, 64_norm, 0.5f));
|
||||
REQUIRE(!region.registerNoteOffNormalized(41, 64_norm, 0.5f));
|
||||
REQUIRE(!region.registerCCNormalized(63, 64_norm));
|
||||
REQUIRE(!region.registerNoteOn(40, 64_norm, 0.5f));
|
||||
REQUIRE(region.registerNoteOff(40, 64_norm, 0.5f));
|
||||
REQUIRE(!region.registerNoteOn(41, 64_norm, 0.5f));
|
||||
REQUIRE(!region.registerNoteOff(41, 64_norm, 0.5f));
|
||||
REQUIRE(!region.registerCC(63, 64_norm));
|
||||
}
|
||||
// TODO: first and legato triggers
|
||||
SECTION("lovel and hivel")
|
||||
|
|
@ -64,11 +64,11 @@ TEST_CASE("Basic triggers", "Region triggers")
|
|||
region.parseOpcode({ "key", "40" });
|
||||
region.parseOpcode({ "lovel", "60" });
|
||||
region.parseOpcode({ "hivel", "70" });
|
||||
REQUIRE(region.registerNoteOnNormalized(40, 64_norm, 0.5f));
|
||||
REQUIRE(region.registerNoteOnNormalized(40, 60_norm, 0.5f));
|
||||
REQUIRE(region.registerNoteOnNormalized(40, 70_norm, 0.5f));
|
||||
REQUIRE(!region.registerNoteOnNormalized(41, 71_norm, 0.5f));
|
||||
REQUIRE(!region.registerNoteOnNormalized(41, 59_norm, 0.5f));
|
||||
REQUIRE(region.registerNoteOn(40, 64_norm, 0.5f));
|
||||
REQUIRE(region.registerNoteOn(40, 60_norm, 0.5f));
|
||||
REQUIRE(region.registerNoteOn(40, 70_norm, 0.5f));
|
||||
REQUIRE(!region.registerNoteOn(41, 71_norm, 0.5f));
|
||||
REQUIRE(!region.registerNoteOn(41, 59_norm, 0.5f));
|
||||
}
|
||||
|
||||
SECTION("lorand and hirand")
|
||||
|
|
@ -76,54 +76,54 @@ TEST_CASE("Basic triggers", "Region triggers")
|
|||
region.parseOpcode({ "key", "40" });
|
||||
region.parseOpcode({ "lorand", "0.35" });
|
||||
region.parseOpcode({ "hirand", "0.40" });
|
||||
REQUIRE(!region.registerNoteOnNormalized(40, 64_norm, 0.34f));
|
||||
REQUIRE(region.registerNoteOnNormalized(40, 64_norm, 0.35f));
|
||||
REQUIRE(region.registerNoteOnNormalized(40, 64_norm, 0.36f));
|
||||
REQUIRE(region.registerNoteOnNormalized(40, 64_norm, 0.37f));
|
||||
REQUIRE(region.registerNoteOnNormalized(40, 64_norm, 0.38f));
|
||||
REQUIRE(region.registerNoteOnNormalized(40, 64_norm, 0.39f));
|
||||
REQUIRE(!region.registerNoteOnNormalized(40, 64_norm, 0.40f));
|
||||
REQUIRE(!region.registerNoteOnNormalized(40, 64_norm, 0.41f));
|
||||
REQUIRE(!region.registerNoteOn(40, 64_norm, 0.34f));
|
||||
REQUIRE(region.registerNoteOn(40, 64_norm, 0.35f));
|
||||
REQUIRE(region.registerNoteOn(40, 64_norm, 0.36f));
|
||||
REQUIRE(region.registerNoteOn(40, 64_norm, 0.37f));
|
||||
REQUIRE(region.registerNoteOn(40, 64_norm, 0.38f));
|
||||
REQUIRE(region.registerNoteOn(40, 64_norm, 0.39f));
|
||||
REQUIRE(!region.registerNoteOn(40, 64_norm, 0.40f));
|
||||
REQUIRE(!region.registerNoteOn(40, 64_norm, 0.41f));
|
||||
}
|
||||
|
||||
SECTION("lorand and hirand on 1.0f")
|
||||
{
|
||||
region.parseOpcode({ "key", "40" });
|
||||
region.parseOpcode({ "lorand", "0.35" });
|
||||
REQUIRE(!region.registerNoteOnNormalized(40, 64_norm, 0.34f));
|
||||
REQUIRE(region.registerNoteOnNormalized(40, 64_norm, 0.35f));
|
||||
REQUIRE(region.registerNoteOnNormalized(40, 64_norm, 1.0f));
|
||||
REQUIRE(!region.registerNoteOn(40, 64_norm, 0.34f));
|
||||
REQUIRE(region.registerNoteOn(40, 64_norm, 0.35f));
|
||||
REQUIRE(region.registerNoteOn(40, 64_norm, 1.0f));
|
||||
}
|
||||
|
||||
SECTION("Disable key trigger")
|
||||
{
|
||||
region.parseOpcode({ "key", "40" });
|
||||
REQUIRE(region.registerNoteOnNormalized(40, 64_norm, 1.0f));
|
||||
REQUIRE(region.registerNoteOn(40, 64_norm, 1.0f));
|
||||
region.parseOpcode({ "hikey", "-1" });
|
||||
REQUIRE(!region.registerNoteOnNormalized(40, 64_norm, 1.0f));
|
||||
REQUIRE(!region.registerNoteOn(40, 64_norm, 1.0f));
|
||||
region.parseOpcode({ "hikey", "40" });
|
||||
REQUIRE(region.registerNoteOnNormalized(40, 64_norm, 1.0f));
|
||||
REQUIRE(region.registerNoteOn(40, 64_norm, 1.0f));
|
||||
region.parseOpcode({ "key", "-1" });
|
||||
REQUIRE(!region.registerNoteOnNormalized(40, 64_norm, 1.0f));
|
||||
REQUIRE(!region.registerNoteOn(40, 64_norm, 1.0f));
|
||||
region.parseOpcode({ "key", "40" });
|
||||
REQUIRE(region.registerNoteOnNormalized(40, 64_norm, 1.0f));
|
||||
REQUIRE(region.registerNoteOn(40, 64_norm, 1.0f));
|
||||
}
|
||||
|
||||
SECTION("on_loccN, on_hiccN")
|
||||
{
|
||||
region.parseOpcode({ "on_locc47", "64" });
|
||||
region.parseOpcode({ "on_hicc47", "68" });
|
||||
REQUIRE(!region.registerCCNormalized(47, 63_norm));
|
||||
REQUIRE(!region.registerCCNormalized(47, 64_norm));
|
||||
REQUIRE(!region.registerCCNormalized(47, 65_norm));
|
||||
REQUIRE(!region.registerCC(47, 63_norm));
|
||||
REQUIRE(!region.registerCC(47, 64_norm));
|
||||
REQUIRE(!region.registerCC(47, 65_norm));
|
||||
region.parseOpcode({ "hikey", "-1" });
|
||||
REQUIRE(region.registerCCNormalized(47, 64_norm));
|
||||
REQUIRE(region.registerCCNormalized(47, 65_norm));
|
||||
REQUIRE(region.registerCCNormalized(47, 66_norm));
|
||||
REQUIRE(region.registerCCNormalized(47, 67_norm));
|
||||
REQUIRE(region.registerCCNormalized(47, 68_norm));
|
||||
REQUIRE(!region.registerCCNormalized(47, 69_norm));
|
||||
REQUIRE(!region.registerCCNormalized(40, 64_norm));
|
||||
REQUIRE(region.registerCC(47, 64_norm));
|
||||
REQUIRE(region.registerCC(47, 65_norm));
|
||||
REQUIRE(region.registerCC(47, 66_norm));
|
||||
REQUIRE(region.registerCC(47, 67_norm));
|
||||
REQUIRE(region.registerCC(47, 68_norm));
|
||||
REQUIRE(!region.registerCC(47, 69_norm));
|
||||
REQUIRE(!region.registerCC(40, 64_norm));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -138,15 +138,15 @@ TEST_CASE("Legato triggers", "Region triggers")
|
|||
region.parseOpcode({ "hikey", "50" });
|
||||
region.parseOpcode({ "trigger", "first" });
|
||||
midiState.noteOnEventNormalized(0, 40, 64_norm);
|
||||
REQUIRE(region.registerNoteOnNormalized(40, 64_norm, 0.5f));
|
||||
REQUIRE(region.registerNoteOn(40, 64_norm, 0.5f));
|
||||
midiState.noteOnEventNormalized(0, 41, 64_norm);
|
||||
REQUIRE(!region.registerNoteOnNormalized(41, 64_norm, 0.5f));
|
||||
REQUIRE(!region.registerNoteOn(41, 64_norm, 0.5f));
|
||||
midiState.noteOffEventNormalized(0, 40, 0_norm);
|
||||
region.registerNoteOffNormalized(40, 0_norm, 0.5f);
|
||||
region.registerNoteOff(40, 0_norm, 0.5f);
|
||||
midiState.noteOffEventNormalized(0, 41, 0_norm);
|
||||
region.registerNoteOffNormalized(41, 0_norm, 0.5f);
|
||||
region.registerNoteOff(41, 0_norm, 0.5f);
|
||||
midiState.noteOnEventNormalized(0, 42, 64_norm);
|
||||
REQUIRE(region.registerNoteOnNormalized(42, 64_norm, 0.5f));
|
||||
REQUIRE(region.registerNoteOn(42, 64_norm, 0.5f));
|
||||
}
|
||||
|
||||
SECTION("Second note playing")
|
||||
|
|
@ -155,14 +155,14 @@ TEST_CASE("Legato triggers", "Region triggers")
|
|||
region.parseOpcode({ "hikey", "50" });
|
||||
region.parseOpcode({ "trigger", "legato" });
|
||||
midiState.noteOnEventNormalized(0, 40, 64_norm);
|
||||
REQUIRE(!region.registerNoteOnNormalized(40, 64_norm, 0.5f));
|
||||
REQUIRE(!region.registerNoteOn(40, 64_norm, 0.5f));
|
||||
midiState.noteOnEventNormalized(0, 41, 64_norm);
|
||||
REQUIRE(region.registerNoteOnNormalized(41, 64_norm, 0.5f));
|
||||
REQUIRE(region.registerNoteOn(41, 64_norm, 0.5f));
|
||||
midiState.noteOffEventNormalized(0, 40, 64_norm);
|
||||
region.registerNoteOffNormalized(40, 0_norm, 0.5f);
|
||||
region.registerNoteOff(40, 0_norm, 0.5f);
|
||||
midiState.noteOffEventNormalized(0, 41, 64_norm);
|
||||
region.registerNoteOffNormalized(41, 0_norm, 0.5f);
|
||||
region.registerNoteOff(41, 0_norm, 0.5f);
|
||||
midiState.noteOnEventNormalized(0, 42, 64_norm);
|
||||
REQUIRE(!region.registerNoteOnNormalized(42, 64_norm, 0.5f));
|
||||
REQUIRE(!region.registerNoteOn(42, 64_norm, 0.5f));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ TEST_CASE("[Region] Crossfade in on key")
|
|||
region.parseOpcode({ "sample", "*sine" });
|
||||
region.parseOpcode({ "xfin_lokey", "1" });
|
||||
region.parseOpcode({ "xfin_hikey", "3" });
|
||||
REQUIRE( region.getNoteGainNormalized(2, 127_norm) == 0.70711_a );
|
||||
REQUIRE( region.getNoteGainNormalized(1, 127_norm) == 0.0_a );
|
||||
REQUIRE( region.getNoteGainNormalized(3, 127_norm) == 1.0_a );
|
||||
REQUIRE( region.getNoteGain(2, 127_norm) == 0.70711_a );
|
||||
REQUIRE( region.getNoteGain(1, 127_norm) == 0.0_a );
|
||||
REQUIRE( region.getNoteGain(3, 127_norm) == 1.0_a );
|
||||
}
|
||||
|
||||
TEST_CASE("[Region] Crossfade in on key - 2")
|
||||
|
|
@ -33,12 +33,12 @@ TEST_CASE("[Region] Crossfade in on key - 2")
|
|||
region.parseOpcode({ "sample", "*sine" });
|
||||
region.parseOpcode({ "xfin_lokey", "1" });
|
||||
region.parseOpcode({ "xfin_hikey", "5" });
|
||||
REQUIRE( region.getNoteGainNormalized(1, 127_norm) == 0.0_a );
|
||||
REQUIRE( region.getNoteGainNormalized(2, 127_norm) == 0.5_a );
|
||||
REQUIRE( region.getNoteGainNormalized(3, 127_norm) == 0.70711_a );
|
||||
REQUIRE( region.getNoteGainNormalized(4, 127_norm) == 0.86603_a );
|
||||
REQUIRE( region.getNoteGainNormalized(5, 127_norm) == 1.0_a );
|
||||
REQUIRE( region.getNoteGainNormalized(6, 127_norm) == 1.0_a );
|
||||
REQUIRE( region.getNoteGain(1, 127_norm) == 0.0_a );
|
||||
REQUIRE( region.getNoteGain(2, 127_norm) == 0.5_a );
|
||||
REQUIRE( region.getNoteGain(3, 127_norm) == 0.70711_a );
|
||||
REQUIRE( region.getNoteGain(4, 127_norm) == 0.86603_a );
|
||||
REQUIRE( region.getNoteGain(5, 127_norm) == 1.0_a );
|
||||
REQUIRE( region.getNoteGain(6, 127_norm) == 1.0_a );
|
||||
}
|
||||
|
||||
TEST_CASE("[Region] Crossfade in on key - gain")
|
||||
|
|
@ -49,11 +49,11 @@ TEST_CASE("[Region] Crossfade in on key - gain")
|
|||
region.parseOpcode({ "xfin_lokey", "1" });
|
||||
region.parseOpcode({ "xfin_hikey", "5" });
|
||||
region.parseOpcode({ "xf_keycurve", "gain" });
|
||||
REQUIRE( region.getNoteGainNormalized(1, 127_norm) == 0.0_a );
|
||||
REQUIRE( region.getNoteGainNormalized(2, 127_norm) == 0.25_a );
|
||||
REQUIRE( region.getNoteGainNormalized(3, 127_norm) == 0.5_a );
|
||||
REQUIRE( region.getNoteGainNormalized(4, 127_norm) == 0.75_a );
|
||||
REQUIRE( region.getNoteGainNormalized(5, 127_norm) == 1.0_a );
|
||||
REQUIRE( region.getNoteGain(1, 127_norm) == 0.0_a );
|
||||
REQUIRE( region.getNoteGain(2, 127_norm) == 0.25_a );
|
||||
REQUIRE( region.getNoteGain(3, 127_norm) == 0.5_a );
|
||||
REQUIRE( region.getNoteGain(4, 127_norm) == 0.75_a );
|
||||
REQUIRE( region.getNoteGain(5, 127_norm) == 1.0_a );
|
||||
}
|
||||
|
||||
TEST_CASE("[Region] Crossfade out on key")
|
||||
|
|
@ -63,13 +63,13 @@ TEST_CASE("[Region] Crossfade out on key")
|
|||
region.parseOpcode({ "sample", "*sine" });
|
||||
region.parseOpcode({ "xfout_lokey", "51" });
|
||||
region.parseOpcode({ "xfout_hikey", "55" });
|
||||
REQUIRE( region.getNoteGainNormalized(50, 127_norm) == 1.0_a );
|
||||
REQUIRE( region.getNoteGainNormalized(51, 127_norm) == 1.0_a );
|
||||
REQUIRE( region.getNoteGainNormalized(52, 127_norm) == 0.86603_a );
|
||||
REQUIRE( region.getNoteGainNormalized(53, 127_norm) == 0.70711_a );
|
||||
REQUIRE( region.getNoteGainNormalized(54, 127_norm) == 0.5_a );
|
||||
REQUIRE( region.getNoteGainNormalized(55, 127_norm) == 0.0_a );
|
||||
REQUIRE( region.getNoteGainNormalized(56, 127_norm) == 0.0_a );
|
||||
REQUIRE( region.getNoteGain(50, 127_norm) == 1.0_a );
|
||||
REQUIRE( region.getNoteGain(51, 127_norm) == 1.0_a );
|
||||
REQUIRE( region.getNoteGain(52, 127_norm) == 0.86603_a );
|
||||
REQUIRE( region.getNoteGain(53, 127_norm) == 0.70711_a );
|
||||
REQUIRE( region.getNoteGain(54, 127_norm) == 0.5_a );
|
||||
REQUIRE( region.getNoteGain(55, 127_norm) == 0.0_a );
|
||||
REQUIRE( region.getNoteGain(56, 127_norm) == 0.0_a );
|
||||
}
|
||||
|
||||
TEST_CASE("[Region] Crossfade out on key - gain")
|
||||
|
|
@ -80,13 +80,13 @@ TEST_CASE("[Region] Crossfade out on key - gain")
|
|||
region.parseOpcode({ "xfout_lokey", "51" });
|
||||
region.parseOpcode({ "xfout_hikey", "55" });
|
||||
region.parseOpcode({ "xf_keycurve", "gain" });
|
||||
REQUIRE( region.getNoteGainNormalized(50, 127_norm) == 1.0_a );
|
||||
REQUIRE( region.getNoteGainNormalized(51, 127_norm) == 1.0_a );
|
||||
REQUIRE( region.getNoteGainNormalized(52, 127_norm) == 0.75_a );
|
||||
REQUIRE( region.getNoteGainNormalized(53, 127_norm) == 0.5_a );
|
||||
REQUIRE( region.getNoteGainNormalized(54, 127_norm) == 0.25_a );
|
||||
REQUIRE( region.getNoteGainNormalized(55, 127_norm) == 0.0_a );
|
||||
REQUIRE( region.getNoteGainNormalized(56, 127_norm) == 0.0_a );
|
||||
REQUIRE( region.getNoteGain(50, 127_norm) == 1.0_a );
|
||||
REQUIRE( region.getNoteGain(51, 127_norm) == 1.0_a );
|
||||
REQUIRE( region.getNoteGain(52, 127_norm) == 0.75_a );
|
||||
REQUIRE( region.getNoteGain(53, 127_norm) == 0.5_a );
|
||||
REQUIRE( region.getNoteGain(54, 127_norm) == 0.25_a );
|
||||
REQUIRE( region.getNoteGain(55, 127_norm) == 0.0_a );
|
||||
REQUIRE( region.getNoteGain(56, 127_norm) == 0.0_a );
|
||||
}
|
||||
|
||||
TEST_CASE("[Region] Crossfade in on velocity")
|
||||
|
|
@ -97,13 +97,13 @@ TEST_CASE("[Region] Crossfade in on velocity")
|
|||
region.parseOpcode({ "xfin_lovel", "20" });
|
||||
region.parseOpcode({ "xfin_hivel", "24" });
|
||||
region.parseOpcode({ "amp_veltrack", "0" });
|
||||
REQUIRE( region.getNoteGainNormalized(1, 19_norm) == 0.0_a );
|
||||
REQUIRE( region.getNoteGainNormalized(1, 20_norm) == 0.0_a );
|
||||
REQUIRE( region.getNoteGainNormalized(2, 21_norm) == 0.5_a );
|
||||
REQUIRE( region.getNoteGainNormalized(3, 22_norm) == 0.70711_a );
|
||||
REQUIRE( region.getNoteGainNormalized(4, 23_norm) == 0.86603_a );
|
||||
REQUIRE( region.getNoteGainNormalized(5, 24_norm) == 1.0_a );
|
||||
REQUIRE( region.getNoteGainNormalized(6, 25_norm) == 1.0_a );
|
||||
REQUIRE( region.getNoteGain(1, 19_norm) == 0.0_a );
|
||||
REQUIRE( region.getNoteGain(1, 20_norm) == 0.0_a );
|
||||
REQUIRE( region.getNoteGain(2, 21_norm) == 0.5_a );
|
||||
REQUIRE( region.getNoteGain(3, 22_norm) == 0.70711_a );
|
||||
REQUIRE( region.getNoteGain(4, 23_norm) == 0.86603_a );
|
||||
REQUIRE( region.getNoteGain(5, 24_norm) == 1.0_a );
|
||||
REQUIRE( region.getNoteGain(6, 25_norm) == 1.0_a );
|
||||
}
|
||||
|
||||
TEST_CASE("[Region] Crossfade in on vel - gain")
|
||||
|
|
@ -115,13 +115,13 @@ TEST_CASE("[Region] Crossfade in on vel - gain")
|
|||
region.parseOpcode({ "xfin_hivel", "24" });
|
||||
region.parseOpcode({ "xf_velcurve", "gain" });
|
||||
region.parseOpcode({ "amp_veltrack", "0" });
|
||||
REQUIRE( region.getNoteGainNormalized(1, 19_norm) == 0.0_a );
|
||||
REQUIRE( region.getNoteGainNormalized(1, 20_norm) == 0.0_a );
|
||||
REQUIRE( region.getNoteGainNormalized(2, 21_norm) == 0.25_a );
|
||||
REQUIRE( region.getNoteGainNormalized(3, 22_norm) == 0.5_a );
|
||||
REQUIRE( region.getNoteGainNormalized(4, 23_norm) == 0.75_a );
|
||||
REQUIRE( region.getNoteGainNormalized(5, 24_norm) == 1.0_a );
|
||||
REQUIRE( region.getNoteGainNormalized(5, 25_norm) == 1.0_a );
|
||||
REQUIRE( region.getNoteGain(1, 19_norm) == 0.0_a );
|
||||
REQUIRE( region.getNoteGain(1, 20_norm) == 0.0_a );
|
||||
REQUIRE( region.getNoteGain(2, 21_norm) == 0.25_a );
|
||||
REQUIRE( region.getNoteGain(3, 22_norm) == 0.5_a );
|
||||
REQUIRE( region.getNoteGain(4, 23_norm) == 0.75_a );
|
||||
REQUIRE( region.getNoteGain(5, 24_norm) == 1.0_a );
|
||||
REQUIRE( region.getNoteGain(5, 25_norm) == 1.0_a );
|
||||
}
|
||||
|
||||
TEST_CASE("[Region] Crossfade out on vel")
|
||||
|
|
@ -132,13 +132,13 @@ TEST_CASE("[Region] Crossfade out on vel")
|
|||
region.parseOpcode({ "xfout_lovel", "51" });
|
||||
region.parseOpcode({ "xfout_hivel", "55" });
|
||||
region.parseOpcode({ "amp_veltrack", "0" });
|
||||
REQUIRE( region.getNoteGainNormalized(5, 50_norm) == 1.0_a );
|
||||
REQUIRE( region.getNoteGainNormalized(5, 51_norm) == 1.0_a );
|
||||
REQUIRE( region.getNoteGainNormalized(5, 52_norm) == 0.86603_a );
|
||||
REQUIRE( region.getNoteGainNormalized(5, 53_norm) == 0.70711_a );
|
||||
REQUIRE( region.getNoteGainNormalized(5, 54_norm) == 0.5_a );
|
||||
REQUIRE( region.getNoteGainNormalized(5, 55_norm) == 0.0_a );
|
||||
REQUIRE( region.getNoteGainNormalized(5, 56_norm) == 0.0_a );
|
||||
REQUIRE( region.getNoteGain(5, 50_norm) == 1.0_a );
|
||||
REQUIRE( region.getNoteGain(5, 51_norm) == 1.0_a );
|
||||
REQUIRE( region.getNoteGain(5, 52_norm) == 0.86603_a );
|
||||
REQUIRE( region.getNoteGain(5, 53_norm) == 0.70711_a );
|
||||
REQUIRE( region.getNoteGain(5, 54_norm) == 0.5_a );
|
||||
REQUIRE( region.getNoteGain(5, 55_norm) == 0.0_a );
|
||||
REQUIRE( region.getNoteGain(5, 56_norm) == 0.0_a );
|
||||
}
|
||||
|
||||
TEST_CASE("[Region] Crossfade out on vel - gain")
|
||||
|
|
@ -150,13 +150,13 @@ TEST_CASE("[Region] Crossfade out on vel - gain")
|
|||
region.parseOpcode({ "xfout_hivel", "55" });
|
||||
region.parseOpcode({ "xf_velcurve", "gain" });
|
||||
region.parseOpcode({ "amp_veltrack", "0" });
|
||||
REQUIRE( region.getNoteGainNormalized(56, 50_norm) == 1.0_a );
|
||||
REQUIRE( region.getNoteGainNormalized(56, 51_norm) == 1.0_a );
|
||||
REQUIRE( region.getNoteGainNormalized(56, 52_norm) == 0.75_a );
|
||||
REQUIRE( region.getNoteGainNormalized(56, 53_norm) == 0.5_a );
|
||||
REQUIRE( region.getNoteGainNormalized(56, 54_norm) == 0.25_a );
|
||||
REQUIRE( region.getNoteGainNormalized(56, 55_norm) == 0.0_a );
|
||||
REQUIRE( region.getNoteGainNormalized(56, 56_norm) == 0.0_a );
|
||||
REQUIRE( region.getNoteGain(56, 50_norm) == 1.0_a );
|
||||
REQUIRE( region.getNoteGain(56, 51_norm) == 1.0_a );
|
||||
REQUIRE( region.getNoteGain(56, 52_norm) == 0.75_a );
|
||||
REQUIRE( region.getNoteGain(56, 53_norm) == 0.5_a );
|
||||
REQUIRE( region.getNoteGain(56, 54_norm) == 0.25_a );
|
||||
REQUIRE( region.getNoteGain(56, 55_norm) == 0.0_a );
|
||||
REQUIRE( region.getNoteGain(56, 56_norm) == 0.0_a );
|
||||
}
|
||||
|
||||
TEST_CASE("[Region] Crossfade in on CC")
|
||||
|
|
@ -234,8 +234,8 @@ TEST_CASE("[Region] Velocity bug for extreme values - veltrack at 0")
|
|||
sfz::Region region { midiState };
|
||||
region.parseOpcode({ "sample", "*sine" });
|
||||
region.parseOpcode({ "amp_veltrack", "0" });
|
||||
REQUIRE( region.getNoteGainNormalized(64, 127_norm) == 1.0_a );
|
||||
REQUIRE( region.getNoteGainNormalized(64, 0_norm) == 1.0_a );
|
||||
REQUIRE( region.getNoteGain(64, 127_norm) == 1.0_a );
|
||||
REQUIRE( region.getNoteGain(64, 0_norm) == 1.0_a );
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -245,8 +245,8 @@ TEST_CASE("[Region] Velocity bug for extreme values - positive veltrack")
|
|||
sfz::Region region { midiState };
|
||||
region.parseOpcode({ "sample", "*sine" });
|
||||
region.parseOpcode({ "amp_veltrack", "100" });
|
||||
REQUIRE( region.getNoteGainNormalized(64, 127_norm) == 1.0_a );
|
||||
REQUIRE( region.getNoteGainNormalized(64, 0_norm) == Approx(0.0).margin(0.0001) );
|
||||
REQUIRE( region.getNoteGain(64, 127_norm) == 1.0_a );
|
||||
REQUIRE( region.getNoteGain(64, 0_norm) == Approx(0.0).margin(0.0001) );
|
||||
}
|
||||
|
||||
TEST_CASE("[Region] Velocity bug for extreme values - negative veltrack")
|
||||
|
|
@ -255,8 +255,8 @@ TEST_CASE("[Region] Velocity bug for extreme values - negative veltrack")
|
|||
sfz::Region region { midiState };
|
||||
region.parseOpcode({ "sample", "*sine" });
|
||||
region.parseOpcode({ "amp_veltrack", "-100" });
|
||||
REQUIRE( region.getNoteGainNormalized(64, 127_norm) == Approx(0.0).margin(0.0001) );
|
||||
REQUIRE( region.getNoteGainNormalized(64, 0_norm) == 1.0_a );
|
||||
REQUIRE( region.getNoteGain(64, 127_norm) == Approx(0.0).margin(0.0001) );
|
||||
REQUIRE( region.getNoteGain(64, 0_norm) == 1.0_a );
|
||||
}
|
||||
|
||||
TEST_CASE("[Region] rt_decay")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue