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

View file

@ -347,11 +347,11 @@ struct Region {
// Region logic: MIDI conditions // Region logic: MIDI conditions
Range<float> bendRange { Default::bendValueRange }; // hibend and lobend Range<float> bendRange { Default::bendValueRange }; // hibend and lobend
CCMap<Range<float>> ccConditions { Default::ccValueRange }; 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<std::string> keyswitchLabel {};
absl::optional<uint8_t> keyswitchUp {}; // sw_up absl::optional<uint8_t> upKeyswitch {}; // sw_up
absl::optional<uint8_t> keyswitchDown {}; // sw_down absl::optional<uint8_t> downKeyswitch {}; // sw_down
absl::optional<uint8_t> previousNote {}; // sw_previous absl::optional<uint8_t> previousKeyswitch {}; // sw_previous
SfzVelocityOverride velocityOverride { Default::velocityOverride }; // sw_vel SfzVelocityOverride velocityOverride { Default::velocityOverride }; // sw_vel
bool checkSustain { Default::checkSustain }; // sustain_sw bool checkSustain { Default::checkSustain }; // sustain_sw
bool checkSostenuto { Default::checkSostenuto }; // sostenuto_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) if (octaveOffset != 0 || noteOffset != 0)
lastRegion->offsetAllKeys(octaveOffset * 12 + noteOffset); lastRegion->offsetAllKeys(octaveOffset * 12 + noteOffset);
if (lastRegion->keyswitch) if (lastRegion->lastKeyswitch)
lastKeyswitchLists[*lastRegion->keyswitch].push_back(lastRegion.get()); lastKeyswitchLists[*lastRegion->lastKeyswitch].push_back(lastRegion.get());
if (lastRegion->keyswitchUp) if (lastRegion->upKeyswitch)
upKeyswitchLists[*lastRegion->keyswitchUp].push_back(lastRegion.get()); upKeyswitchLists[*lastRegion->upKeyswitch].push_back(lastRegion.get());
if (lastRegion->keyswitchDown) if (lastRegion->downKeyswitch)
downKeyswitchLists[*lastRegion->keyswitchDown].push_back(lastRegion.get()); downKeyswitchLists[*lastRegion->downKeyswitch].push_back(lastRegion.get());
if (lastRegion->previousNote) if (lastRegion->previousKeyswitch)
previousKeyswitchLists.push_back(lastRegion.get()); previousKeyswitchLists.push_back(lastRegion.get());
// There was a combination of group= and polyphony= on a region, so set the group polyphony // 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) if (currentSwitch)
region->keySwitched = (*currentSwitch == *region->keyswitch); region->keySwitched = (*currentSwitch == *region->lastKeyswitch);
if (region->keyswitchLabel) 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 // 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) 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 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(2)->crossfadeKeyOutRange == Range<uint8_t>(45, 49));
REQUIRE(synth.getRegionView(3)->keyRange == Range<uint8_t>(62, 62)); REQUIRE(synth.getRegionView(3)->keyRange == Range<uint8_t>(62, 62));
REQUIRE( synth.getRegionView(3)->keyswitch ); REQUIRE( synth.getRegionView(3)->lastKeyswitch );
REQUIRE( *synth.getRegionView(3)->keyswitch == 24 ); REQUIRE( *synth.getRegionView(3)->lastKeyswitch == 24 );
REQUIRE( synth.getRegionView(3)->keyswitchUp ); REQUIRE( synth.getRegionView(3)->upKeyswitch );
REQUIRE( *synth.getRegionView(3)->keyswitchUp == 24 ); REQUIRE( *synth.getRegionView(3)->upKeyswitch == 24 );
REQUIRE( synth.getRegionView(3)->keyswitchDown ); REQUIRE( synth.getRegionView(3)->downKeyswitch );
REQUIRE( *synth.getRegionView(3)->keyswitchDown == 24 ); REQUIRE( *synth.getRegionView(3)->downKeyswitch == 24 );
REQUIRE( synth.getRegionView(3)->previousNote ); REQUIRE( synth.getRegionView(3)->previousKeyswitch );
REQUIRE( *synth.getRegionView(3)->previousNote == 61 ); REQUIRE( *synth.getRegionView(3)->previousKeyswitch == 61 );
REQUIRE(synth.getRegionView(4)->keyRange == Range<uint8_t>(76, 76)); REQUIRE(synth.getRegionView(4)->keyRange == Range<uint8_t>(76, 76));
REQUIRE( synth.getRegionView(4)->pitchKeycenter == 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; sfz::Synth synth;
synth.loadSfzString(fs::current_path() / "tests/TestFiles/keyswitches.sfz", R"( 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); REQUIRE(synth.getNumActiveVoices(true) == 2);
} }
TEST_CASE("[Keyswitches] No keyswitch range") TEST_CASE("[Keyswitches] No lastKeyswitch range")
{ {
sfz::Synth synth; sfz::Synth synth;
synth.loadSfzString(fs::current_path() / "tests/TestFiles/keyswitches.sfz", R"( 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); REQUIRE(synth.getNumActiveVoices(true) == 2);
} }
TEST_CASE("[Keyswitches] Out of keyswitch range") TEST_CASE("[Keyswitches] Out of lastKeyswitch range")
{ {
sfz::Synth synth; sfz::Synth synth;
synth.loadSfzString(fs::current_path() / "tests/TestFiles/keyswitches.sfz", R"( 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); REQUIRE(synth.getNumActiveVoices(true) == 2);
} }
TEST_CASE("[Keyswitches] Overlapping key and keyswitch range") TEST_CASE("[Keyswitches] Overlapping key and lastKeyswitch range")
{ {
sfz::Synth synth; sfz::Synth synth;
synth.loadSfzString(fs::current_path() / "tests/TestFiles/keyswitches.sfz", R"( synth.loadSfzString(fs::current_path() / "tests/TestFiles/keyswitches.sfz", R"(

View file

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