Handle case-insensitivity in the cleanup
This commit is contained in:
parent
66d4a0d175
commit
6472784baf
3 changed files with 13 additions and 6 deletions
|
|
@ -8,6 +8,7 @@
|
|||
#include "Opcode.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/strings/str_cat.h"
|
||||
#include "absl/strings/ascii.h"
|
||||
#include <string>
|
||||
|
||||
namespace sfz {
|
||||
|
|
@ -16,6 +17,9 @@ static std::string cleanUpOpcodeName(absl::string_view rawOpcode, OpcodeScope sc
|
|||
{
|
||||
std::string opcode { rawOpcode };
|
||||
|
||||
// always convert it to lower case
|
||||
absl::AsciiStrToLower(&opcode);
|
||||
|
||||
/*!re2c
|
||||
re2c:flags:posix-captures = 1;
|
||||
re2c:define:YYCTYPE = char;
|
||||
|
|
|
|||
|
|
@ -207,7 +207,6 @@ void sfz::Synth::handleControlOpcodes(const std::vector<Opcode>& members)
|
|||
const Opcode member = rawMember.cleanUp(kOpcodeScopeControl);
|
||||
|
||||
switch (member.lettersOnlyHash) {
|
||||
case hash("Set_cc&"): // fallthrough
|
||||
case hash("set_cc&"):
|
||||
if (Default::ccNumberRange.containsWithEnd(member.parameters.back())) {
|
||||
const auto ccValue = readOpcode(member.value, Default::midi7Range);
|
||||
|
|
@ -215,7 +214,6 @@ void sfz::Synth::handleControlOpcodes(const std::vector<Opcode>& members)
|
|||
resources.midiState.ccEvent(0, member.parameters.back(), normalizeCC(*ccValue));
|
||||
}
|
||||
break;
|
||||
case hash("Set_hdcc&"): // fallthrough
|
||||
case hash("set_hdcc&"):
|
||||
if (Default::ccNumberRange.containsWithEnd(member.parameters.back())) {
|
||||
const auto ccValue = readOpcode(member.value, Default::normalizedRange);
|
||||
|
|
@ -223,7 +221,6 @@ void sfz::Synth::handleControlOpcodes(const std::vector<Opcode>& members)
|
|||
resources.midiState.ccEvent(0, member.parameters.back(), *ccValue);
|
||||
}
|
||||
break;
|
||||
case hash("Label_cc&"): // fallthrough
|
||||
case hash("label_cc&"):
|
||||
if (Default::ccNumberRange.containsWithEnd(member.parameters.back()))
|
||||
ccLabels.emplace_back(member.parameters.back(), std::string(member.value));
|
||||
|
|
@ -232,8 +229,6 @@ void sfz::Synth::handleControlOpcodes(const std::vector<Opcode>& members)
|
|||
if (Default::keyRange.containsWithEnd(member.parameters.back()))
|
||||
keyLabels.emplace_back(member.parameters.back(), std::string(member.value));
|
||||
break;
|
||||
case hash("Default_path"):
|
||||
// fallthrough
|
||||
case hash("default_path"):
|
||||
defaultPath = absl::StrReplaceAll(trim(member.value), { { "\\", "/" } });
|
||||
DBG("Changing default sample path to " << defaultPath);
|
||||
|
|
|
|||
|
|
@ -161,9 +161,13 @@ TEST_CASE("[Opcode] Derived names")
|
|||
|
||||
TEST_CASE("[Opcode] Normalization")
|
||||
{
|
||||
// *_ccN
|
||||
|
||||
REQUIRE(sfz::Opcode("foo_cc7", "").cleanUp(sfz::kOpcodeScopeRegion).opcode == "foo_oncc7");
|
||||
REQUIRE(sfz::Opcode("foo_cc7", "").cleanUp(sfz::kOpcodeScopeControl).opcode == "foo_cc7");
|
||||
|
||||
// <region>
|
||||
|
||||
static const std::pair<absl::string_view, absl::string_view> regionSpecific[] = {
|
||||
// LFO SFZv1
|
||||
{"amplfo_depthcc1", "amplfo_depth_oncc1"},
|
||||
|
|
@ -224,7 +228,7 @@ TEST_CASE("[Opcode] Normalization")
|
|||
REQUIRE(sfz::Opcode(input, "").cleanUp(sfz::kOpcodeScopeGeneric).opcode == input);
|
||||
}
|
||||
|
||||
///
|
||||
// <control>
|
||||
|
||||
static const std::pair<absl::string_view, absl::string_view> controlSpecific[] = {
|
||||
// ARIA aliases
|
||||
|
|
@ -237,4 +241,8 @@ TEST_CASE("[Opcode] Normalization")
|
|||
REQUIRE(sfz::Opcode(input, "").cleanUp(sfz::kOpcodeScopeControl).opcode == expected);
|
||||
REQUIRE(sfz::Opcode(input, "").cleanUp(sfz::kOpcodeScopeGeneric).opcode == input);
|
||||
}
|
||||
|
||||
// case
|
||||
|
||||
REQUIRE(sfz::Opcode("SaMpLe", "").cleanUp(sfz::kOpcodeScopeRegion).opcode == "sample");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue