Rename for consistency

This commit is contained in:
Paul Ferrand 2020-10-27 11:19:12 +01:00
parent 6bfc9074d7
commit 9c3de9dadd
6 changed files with 67 additions and 67 deletions

View file

@ -296,21 +296,21 @@ bool sfz::Region::parseOpcode(const Opcode& rawOpcode)
case hash("sw_hikey"):
break;
case hash("sw_last"):
setValueFromOpcode(opcode, keyswitch, Default::keyRange);
setValueFromOpcode(opcode, lastKeyswitch, Default::keyRange);
keySwitched = false;
break;
case hash("sw_label"):
keyswitchLabel = opcode.value;
break;
case hash("sw_down"):
setValueFromOpcode(opcode, keyswitchDown, Default::keyRange);
setValueFromOpcode(opcode, downKeyswitch, Default::keyRange);
keySwitched = false;
break;
case hash("sw_up"):
setValueFromOpcode(opcode, keyswitchUp, Default::keyRange);
setValueFromOpcode(opcode, upKeyswitch, Default::keyRange);
break;
case hash("sw_previous"):
setValueFromOpcode(opcode, previousNote, Default::keyRange);
setValueFromOpcode(opcode, previousKeyswitch, Default::keyRange);
previousKeySwitched = false;
break;
case hash("sw_vel"):
@ -1844,14 +1844,14 @@ void sfz::Region::offsetAllKeys(int offset) noexcept
pitchKeycenter = offsetAndClampKey(pitchKeycenter, offset, Default::keyRange);
// Offset key switches
if (keyswitchUp)
keyswitchUp = offsetAndClampKey(*keyswitchUp, offset, Default::keyRange);
if (keyswitch)
keyswitch = offsetAndClampKey(*keyswitch, offset, Default::keyRange);
if (keyswitchDown)
keyswitchDown = offsetAndClampKey(*keyswitchDown, offset, Default::keyRange);
if (previousNote)
previousNote = offsetAndClampKey(*previousNote, offset, Default::keyRange);
if (upKeyswitch)
upKeyswitch = offsetAndClampKey(*upKeyswitch, offset, Default::keyRange);
if (lastKeyswitch)
lastKeyswitch = offsetAndClampKey(*lastKeyswitch, offset, Default::keyRange);
if (downKeyswitch)
downKeyswitch = offsetAndClampKey(*downKeyswitch, offset, Default::keyRange);
if (previousKeyswitch)
previousKeyswitch = offsetAndClampKey(*previousKeyswitch, offset, Default::keyRange);
// Offset crossfade ranges
if (crossfadeKeyInRange != Default::crossfadeKeyInRange) {

View file

@ -347,11 +347,11 @@ struct Region {
// Region logic: MIDI conditions
Range<float> bendRange { Default::bendValueRange }; // hibend and lobend
CCMap<Range<float>> ccConditions { Default::ccValueRange };
absl::optional<uint8_t> keyswitch {}; // sw_last
absl::optional<uint8_t> lastKeyswitch {}; // sw_last
absl::optional<std::string> keyswitchLabel {};
absl::optional<uint8_t> keyswitchUp {}; // sw_up
absl::optional<uint8_t> keyswitchDown {}; // sw_down
absl::optional<uint8_t> previousNote {}; // sw_previous
absl::optional<uint8_t> upKeyswitch {}; // sw_up
absl::optional<uint8_t> downKeyswitch {}; // sw_down
absl::optional<uint8_t> previousKeyswitch {}; // sw_previous
SfzVelocityOverride velocityOverride { Default::velocityOverride }; // sw_vel
bool checkSustain { Default::checkSustain }; // sustain_sw
bool checkSostenuto { Default::checkSostenuto }; // sostenuto_sw

View file

@ -175,16 +175,16 @@ void sfz::Synth::buildRegion(const std::vector<Opcode>& regionOpcodes)
if (octaveOffset != 0 || noteOffset != 0)
lastRegion->offsetAllKeys(octaveOffset * 12 + noteOffset);
if (lastRegion->keyswitch)
lastKeyswitchLists[*lastRegion->keyswitch].push_back(lastRegion.get());
if (lastRegion->lastKeyswitch)
lastKeyswitchLists[*lastRegion->lastKeyswitch].push_back(lastRegion.get());
if (lastRegion->keyswitchUp)
upKeyswitchLists[*lastRegion->keyswitchUp].push_back(lastRegion.get());
if (lastRegion->upKeyswitch)
upKeyswitchLists[*lastRegion->upKeyswitch].push_back(lastRegion.get());
if (lastRegion->keyswitchDown)
downKeyswitchLists[*lastRegion->keyswitchDown].push_back(lastRegion.get());
if (lastRegion->downKeyswitch)
downKeyswitchLists[*lastRegion->downKeyswitch].push_back(lastRegion.get());
if (lastRegion->previousNote)
if (lastRegion->previousKeyswitch)
previousKeyswitchLists.push_back(lastRegion.get());
// There was a combination of group= and polyphony= on a region, so set the group polyphony
@ -614,12 +614,12 @@ void sfz::Synth::finalizeSfzLoad()
}
}
if (region->keyswitch) {
if (region->lastKeyswitch) {
if (currentSwitch)
region->keySwitched = (*currentSwitch == *region->keyswitch);
region->keySwitched = (*currentSwitch == *region->lastKeyswitch);
if (region->keyswitchLabel)
insertPairUniquely(keyswitchLabels, *region->keyswitch, *region->keyswitchLabel);
insertPairUniquely(keyswitchLabels, *region->lastKeyswitch, *region->keyswitchLabel);
}
// Some regions had group number but no "group-level" opcodes handled the polyphony
@ -1184,7 +1184,7 @@ void sfz::Synth::noteOnDispatch(int delay, int noteNumber, float velocity) noexc
}
for (auto& region : previousKeyswitchLists)
region->previousKeySwitched = (*region->previousNote == noteNumber);
region->previousKeySwitched = (*region->previousKeyswitch == noteNumber);
}
void sfz::Synth::startDelayedReleaseVoices(Region* region, int delay, SisterVoiceRingBuilder& ring) noexcept

View file

@ -463,14 +463,14 @@ TEST_CASE("[Files] Note and octave offsets")
REQUIRE(synth.getRegionView(2)->crossfadeKeyOutRange == Range<uint8_t>(45, 49));
REQUIRE(synth.getRegionView(3)->keyRange == Range<uint8_t>(62, 62));
REQUIRE( synth.getRegionView(3)->keyswitch );
REQUIRE( *synth.getRegionView(3)->keyswitch == 24 );
REQUIRE( synth.getRegionView(3)->keyswitchUp );
REQUIRE( *synth.getRegionView(3)->keyswitchUp == 24 );
REQUIRE( synth.getRegionView(3)->keyswitchDown );
REQUIRE( *synth.getRegionView(3)->keyswitchDown == 24 );
REQUIRE( synth.getRegionView(3)->previousNote );
REQUIRE( *synth.getRegionView(3)->previousNote == 61 );
REQUIRE( synth.getRegionView(3)->lastKeyswitch );
REQUIRE( *synth.getRegionView(3)->lastKeyswitch == 24 );
REQUIRE( synth.getRegionView(3)->upKeyswitch );
REQUIRE( *synth.getRegionView(3)->upKeyswitch == 24 );
REQUIRE( synth.getRegionView(3)->downKeyswitch );
REQUIRE( *synth.getRegionView(3)->downKeyswitch == 24 );
REQUIRE( synth.getRegionView(3)->previousKeyswitch );
REQUIRE( *synth.getRegionView(3)->previousKeyswitch == 61 );
REQUIRE(synth.getRegionView(4)->keyRange == Range<uint8_t>(76, 76));
REQUIRE( synth.getRegionView(4)->pitchKeycenter == 76 );

View file

@ -177,7 +177,7 @@ TEST_CASE("Region activation", "Region tests")
}
}
TEST_CASE("[Keyswitches] Normal keyswitch range")
TEST_CASE("[Keyswitches] Normal lastKeyswitch range")
{
sfz::Synth synth;
synth.loadSfzString(fs::current_path() / "tests/TestFiles/keyswitches.sfz", R"(
@ -196,7 +196,7 @@ TEST_CASE("[Keyswitches] Normal keyswitch range")
REQUIRE(synth.getNumActiveVoices(true) == 2);
}
TEST_CASE("[Keyswitches] No keyswitch range")
TEST_CASE("[Keyswitches] No lastKeyswitch range")
{
sfz::Synth synth;
synth.loadSfzString(fs::current_path() / "tests/TestFiles/keyswitches.sfz", R"(
@ -219,7 +219,7 @@ TEST_CASE("[Keyswitches] No keyswitch range")
REQUIRE(synth.getNumActiveVoices(true) == 2);
}
TEST_CASE("[Keyswitches] Out of keyswitch range")
TEST_CASE("[Keyswitches] Out of lastKeyswitch range")
{
sfz::Synth synth;
synth.loadSfzString(fs::current_path() / "tests/TestFiles/keyswitches.sfz", R"(
@ -238,7 +238,7 @@ TEST_CASE("[Keyswitches] Out of keyswitch range")
REQUIRE(synth.getNumActiveVoices(true) == 2);
}
TEST_CASE("[Keyswitches] Overlapping key and keyswitch range")
TEST_CASE("[Keyswitches] Overlapping key and lastKeyswitch range")
{
sfz::Synth synth;
synth.loadSfzString(fs::current_path() / "tests/TestFiles/keyswitches.sfz", R"(

View file

@ -350,58 +350,58 @@ TEST_CASE("[Region] Parsing opcodes")
SECTION("sw_last")
{
REQUIRE(!region.keyswitch);
REQUIRE(!region.lastKeyswitch);
region.parseOpcode({ "sw_last", "4" });
REQUIRE(region.keyswitch);
REQUIRE(*region.keyswitch == 4);
REQUIRE(region.lastKeyswitch);
REQUIRE(*region.lastKeyswitch == 4);
region.parseOpcode({ "sw_last", "128" });
REQUIRE(region.keyswitch);
REQUIRE(*region.keyswitch == 127);
REQUIRE(region.lastKeyswitch);
REQUIRE(*region.lastKeyswitch == 127);
region.parseOpcode({ "sw_last", "-1" });
REQUIRE(region.keyswitch);
REQUIRE(*region.keyswitch == 0);
REQUIRE(region.lastKeyswitch);
REQUIRE(*region.lastKeyswitch == 0);
}
SECTION("sw_up")
{
REQUIRE(!region.keyswitchUp);
REQUIRE(!region.upKeyswitch);
region.parseOpcode({ "sw_up", "4" });
REQUIRE(region.keyswitchUp);
REQUIRE(*region.keyswitchUp == 4);
REQUIRE(region.upKeyswitch);
REQUIRE(*region.upKeyswitch == 4);
region.parseOpcode({ "sw_up", "128" });
REQUIRE(region.keyswitchUp);
REQUIRE(*region.keyswitchUp == 127);
REQUIRE(region.upKeyswitch);
REQUIRE(*region.upKeyswitch == 127);
region.parseOpcode({ "sw_up", "-1" });
REQUIRE(region.keyswitchUp);
REQUIRE(*region.keyswitchUp == 0);
REQUIRE(region.upKeyswitch);
REQUIRE(*region.upKeyswitch == 0);
}
SECTION("sw_down")
{
REQUIRE(!region.keyswitchDown);
REQUIRE(!region.downKeyswitch);
region.parseOpcode({ "sw_down", "4" });
REQUIRE(region.keyswitchDown);
REQUIRE(*region.keyswitchDown == 4);
REQUIRE(region.downKeyswitch);
REQUIRE(*region.downKeyswitch == 4);
region.parseOpcode({ "sw_down", "128" });
REQUIRE(region.keyswitchDown);
REQUIRE(*region.keyswitchDown == 127);
REQUIRE(region.downKeyswitch);
REQUIRE(*region.downKeyswitch == 127);
region.parseOpcode({ "sw_down", "-1" });
REQUIRE(region.keyswitchDown);
REQUIRE(*region.keyswitchDown == 0);
REQUIRE(region.downKeyswitch);
REQUIRE(*region.downKeyswitch == 0);
}
SECTION("sw_previous")
{
REQUIRE(!region.previousNote);
REQUIRE(!region.previousKeyswitch);
region.parseOpcode({ "sw_previous", "4" });
REQUIRE(region.previousNote);
REQUIRE(*region.previousNote == 4);
REQUIRE(region.previousKeyswitch);
REQUIRE(*region.previousKeyswitch == 4);
region.parseOpcode({ "sw_previous", "128" });
REQUIRE(region.previousNote);
REQUIRE(*region.previousNote == 127);
REQUIRE(region.previousKeyswitch);
REQUIRE(*region.previousKeyswitch == 127);
region.parseOpcode({ "sw_previous", "-1" });
REQUIRE(region.previousNote);
REQUIRE(*region.previousNote == 0);
REQUIRE(region.previousKeyswitch);
REQUIRE(*region.previousKeyswitch == 0);
}
SECTION("sw_vel")