Merge pull request #531 from paulfd/sw-default-region
Handle sw_default in <region>
This commit is contained in:
commit
689102f527
4 changed files with 37 additions and 1 deletions
|
|
@ -1390,11 +1390,13 @@ bool sfz::Region::parseOpcode(const Opcode& rawOpcode)
|
||||||
gainToEffect[effectNumber] = *value / 100;
|
gainToEffect[effectNumber] = *value / 100;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case hash("sw_default"):
|
||||||
|
setValueFromOpcode(opcode, defaultSwitch, Default::keyRange);
|
||||||
|
break;
|
||||||
|
|
||||||
// Ignored opcodes
|
// Ignored opcodes
|
||||||
case hash("hichan"):
|
case hash("hichan"):
|
||||||
case hash("lochan"):
|
case hash("lochan"):
|
||||||
case hash("sw_default"):
|
|
||||||
case hash("ampeg_depth"):
|
case hash("ampeg_depth"):
|
||||||
case hash("ampeg_vel&depth"):
|
case hash("ampeg_vel&depth"):
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -353,6 +353,7 @@ struct Region {
|
||||||
absl::optional<uint8_t> upKeyswitch {}; // sw_up
|
absl::optional<uint8_t> upKeyswitch {}; // sw_up
|
||||||
absl::optional<uint8_t> downKeyswitch {}; // sw_down
|
absl::optional<uint8_t> downKeyswitch {}; // sw_down
|
||||||
absl::optional<uint8_t> previousKeyswitch {}; // sw_previous
|
absl::optional<uint8_t> previousKeyswitch {}; // sw_previous
|
||||||
|
absl::optional<uint8_t> defaultSwitch {};
|
||||||
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
|
||||||
|
|
|
||||||
|
|
@ -193,6 +193,9 @@ void sfz::Synth::buildRegion(const std::vector<Opcode>& regionOpcodes)
|
||||||
if (lastRegion->previousKeyswitch)
|
if (lastRegion->previousKeyswitch)
|
||||||
previousKeyswitchLists.push_back(lastRegion.get());
|
previousKeyswitchLists.push_back(lastRegion.get());
|
||||||
|
|
||||||
|
if (lastRegion->defaultSwitch)
|
||||||
|
currentSwitch = *lastRegion->defaultSwitch;
|
||||||
|
|
||||||
// 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
|
||||||
if (lastRegion->group != Default::group && lastRegion->polyphony != config::maxVoices)
|
if (lastRegion->group != Default::group && lastRegion->polyphony != config::maxVoices)
|
||||||
setGroupPolyphony(lastRegion->group, lastRegion->polyphony);
|
setGroupPolyphony(lastRegion->group, lastRegion->polyphony);
|
||||||
|
|
|
||||||
|
|
@ -497,3 +497,33 @@ TEST_CASE("[Keyswitches] sw_lolast and sw_hilast with sw_default")
|
||||||
REQUIRE(synth.getRegionView(0)->isSwitchedOn());
|
REQUIRE(synth.getRegionView(0)->isSwitchedOn());
|
||||||
REQUIRE(!synth.getRegionView(1)->isSwitchedOn());
|
REQUIRE(!synth.getRegionView(1)->isSwitchedOn());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("[Keyswitches] Multiple sw_default")
|
||||||
|
{
|
||||||
|
sfz::Synth synth;
|
||||||
|
synth.loadSfzString(fs::current_path() / "tests/TestFiles/sw_previous.sfz", R"(
|
||||||
|
<global> sw_default=60
|
||||||
|
<region> sw_last=60 key=70 sample=*saw
|
||||||
|
<group> sw_default=58
|
||||||
|
<region> sw_last=59 key=72 sample=*saw
|
||||||
|
<master> sw_default=59
|
||||||
|
<region> sw_last=62 key=73 sample=*saw
|
||||||
|
)");
|
||||||
|
REQUIRE(!synth.getRegionView(0)->isSwitchedOn());
|
||||||
|
// Only the last one is taken into account
|
||||||
|
REQUIRE(synth.getRegionView(1)->isSwitchedOn());
|
||||||
|
REQUIRE(!synth.getRegionView(2)->isSwitchedOn());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("[Keyswitches] Multiple sw_default, in region")
|
||||||
|
{
|
||||||
|
sfz::Synth synth;
|
||||||
|
synth.loadSfzString(fs::current_path() / "tests/TestFiles/sw_previous.sfz", R"(
|
||||||
|
<global> sw_default=60
|
||||||
|
<region> sw_last=58 key=70 sample=*saw
|
||||||
|
<region> sw_default=58 sw_last=59 key=72 sample=*saw
|
||||||
|
)");
|
||||||
|
REQUIRE(synth.getRegionView(0)->isSwitchedOn());
|
||||||
|
REQUIRE(!synth.getRegionView(1)->isSwitchedOn());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue