Merge pull request #1019 from paulfd/negative-lokey

Negative lokey values don't disable the region
This commit is contained in:
Paul Ferrand 2021-11-10 11:12:26 +01:00 committed by GitHub
commit 862d057bdb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 7 deletions

View file

@ -209,12 +209,7 @@ bool sfz::Region::parseOpcode(const Opcode& rawOpcode, bool cleanOpcode)
break;
// Region logic: key mapping
case hash("lokey"):
{
absl::optional<uint8_t> optValue = opcode.readOptional(Default::loKey);
triggerOnNote = optValue != absl::nullopt;
uint8_t value = optValue.value_or(Default::loKey);
keyRange.setStart(value);
}
keyRange.setStart(opcode.read(Default::loKey));
break;
case hash("hikey"):
{

View file

@ -636,6 +636,7 @@ TEST_CASE("[Values] Triggers on note")
<region> sample=kick.wav key=-1
<region> sample=kick.wav hikey=-1 lokey=12
<region> sample=kick.wav hikey=-1 lokey=-1
<region> sample=kick.wav hikey=0 lokey=12
)");
synth.dispatchMessage(client, 0, "/region0/trigger_on_note", "", nullptr);
synth.dispatchMessage(client, 0, "/region1/trigger_on_note", "", nullptr);
@ -643,12 +644,14 @@ TEST_CASE("[Values] Triggers on note")
// TODO: Double check with Sforzando/rgc
synth.dispatchMessage(client, 0, "/region3/trigger_on_note", "", nullptr);
synth.dispatchMessage(client, 0, "/region4/trigger_on_note", "", nullptr);
synth.dispatchMessage(client, 0, "/region5/trigger_on_note", "", nullptr);
std::vector<std::string> expected {
"/region0/trigger_on_note,T : { }",
"/region1/trigger_on_note,F : { }",
"/region2/trigger_on_note,F : { }",
"/region3/trigger_on_note,T : { }",
"/region3/trigger_on_note,F : { }",
"/region4/trigger_on_note,F : { }",
"/region5/trigger_on_note,T : { }",
};
REQUIRE(messageList == expected);
}