diff --git a/src/sfizz/Region.cpp b/src/sfizz/Region.cpp index f4be5582..d7826720 100644 --- a/src/sfizz/Region.cpp +++ b/src/sfizz/Region.cpp @@ -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) { diff --git a/src/sfizz/Region.h b/src/sfizz/Region.h index a88ab965..996eec4e 100644 --- a/src/sfizz/Region.h +++ b/src/sfizz/Region.h @@ -347,11 +347,11 @@ struct Region { // Region logic: MIDI conditions Range bendRange { Default::bendValueRange }; // hibend and lobend CCMap> ccConditions { Default::ccValueRange }; - absl::optional keyswitch {}; // sw_last + absl::optional lastKeyswitch {}; // sw_last absl::optional keyswitchLabel {}; - absl::optional keyswitchUp {}; // sw_up - absl::optional keyswitchDown {}; // sw_down - absl::optional previousNote {}; // sw_previous + absl::optional upKeyswitch {}; // sw_up + absl::optional downKeyswitch {}; // sw_down + absl::optional previousKeyswitch {}; // sw_previous SfzVelocityOverride velocityOverride { Default::velocityOverride }; // sw_vel bool checkSustain { Default::checkSustain }; // sustain_sw bool checkSostenuto { Default::checkSostenuto }; // sostenuto_sw diff --git a/src/sfizz/Synth.cpp b/src/sfizz/Synth.cpp index 143e22ba..631a5b43 100644 --- a/src/sfizz/Synth.cpp +++ b/src/sfizz/Synth.cpp @@ -175,16 +175,16 @@ void sfz::Synth::buildRegion(const std::vector& 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 diff --git a/tests/FilesT.cpp b/tests/FilesT.cpp index 8917e591..b0a19757 100644 --- a/tests/FilesT.cpp +++ b/tests/FilesT.cpp @@ -463,14 +463,14 @@ TEST_CASE("[Files] Note and octave offsets") REQUIRE(synth.getRegionView(2)->crossfadeKeyOutRange == Range(45, 49)); REQUIRE(synth.getRegionView(3)->keyRange == Range(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(76, 76)); REQUIRE( synth.getRegionView(4)->pitchKeycenter == 76 ); diff --git a/tests/RegionActivationT.cpp b/tests/RegionActivationT.cpp index 7a08ce76..0763b56f 100644 --- a/tests/RegionActivationT.cpp +++ b/tests/RegionActivationT.cpp @@ -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"( diff --git a/tests/RegionT.cpp b/tests/RegionT.cpp index 2b1cc780..7e20583c 100644 --- a/tests/RegionT.cpp +++ b/tests/RegionT.cpp @@ -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")