diff --git a/src/sfizz/Opcode.h b/src/sfizz/Opcode.h index 29f05c7b..4d77a96d 100644 --- a/src/sfizz/Opcode.h +++ b/src/sfizz/Opcode.h @@ -42,6 +42,8 @@ enum OpcodeCategory { enum OpcodeScope { //! unknown scope or other kOpcodeScopeGeneric, + //! control scope + kOpcodeScopeControl, //! region scope kOpcodeScopeRegion, //! effect scope diff --git a/src/sfizz/OpcodeCleanup.re b/src/sfizz/OpcodeCleanup.re index 795fe053..87658347 100644 --- a/src/sfizz/OpcodeCleanup.re +++ b/src/sfizz/OpcodeCleanup.re @@ -45,24 +45,28 @@ static std::string cleanUpOpcodeName(absl::string_view rawOpcode, OpcodeScope sc //-------------------------------------------------------------------------- + if (scope == kOpcodeScopeRegion) { + YYCURSOR = opcode.c_str(); /*!re2c (any) "_cc" (number) END { opcode = absl::StrCat(group(1), "_oncc", group(2)); - goto end_generic; + goto end_region_oncc; } * { - goto end_generic; + goto end_region_oncc; } */ -end_generic: +end_region_oncc: /* end */; + } // scope == kOpcodeScopeRegion + //-------------------------------------------------------------------------- if (scope == kOpcodeScopeRegion) { @@ -168,6 +172,31 @@ end_region: //-------------------------------------------------------------------------- + if (scope == kOpcodeScopeControl) { + + YYCURSOR = opcode.c_str(); + + /*!re2c + + "set_realcc" (number) END { + opcode = absl::StrCat("set_hdcc", group(1)); + goto end_control; + } + + * { + goto end_control; + } + + */ + +end_control: + /* end */; + + } // scope == kOpcodeScopeControl + + //-------------------------------------------------------------------------- + + #undef YYMAXNMATCH return opcode; diff --git a/src/sfizz/Synth.cpp b/src/sfizz/Synth.cpp index 52b80c9a..e458a8f8 100644 --- a/src/sfizz/Synth.cpp +++ b/src/sfizz/Synth.cpp @@ -199,7 +199,9 @@ void sfz::Synth::handleGroupOpcodes(const std::vector& members, const st void sfz::Synth::handleControlOpcodes(const std::vector& members) { - for (auto& member : members) { + for (auto& rawMember : members) { + const Opcode member = rawMember.cleanUp(kOpcodeScopeControl); + switch (member.lettersOnlyHash) { case hash("Set_cc&"): // fallthrough case hash("set_cc&"): @@ -211,8 +213,6 @@ void sfz::Synth::handleControlOpcodes(const std::vector& members) break; case hash("Set_hdcc&"): // fallthrough case hash("set_hdcc&"): - case hash("Set_realcc&"): - case hash("set_realcc&"): if (Default::ccNumberRange.containsWithEnd(member.parameters.back())) { const auto ccValue = readOpcode(member.value, Default::normalizedRange); if (ccValue) diff --git a/tests/OpcodeT.cpp b/tests/OpcodeT.cpp index ed3fb40e..374336b7 100644 --- a/tests/OpcodeT.cpp +++ b/tests/OpcodeT.cpp @@ -161,8 +161,8 @@ TEST_CASE("[Opcode] Derived names") TEST_CASE("[Opcode] Normalization") { - REQUIRE(sfz::Opcode("foo_cc7", "").cleanUp(sfz::kOpcodeScopeGeneric).opcode == "foo_oncc7"); REQUIRE(sfz::Opcode("foo_cc7", "").cleanUp(sfz::kOpcodeScopeRegion).opcode == "foo_oncc7"); + REQUIRE(sfz::Opcode("foo_cc7", "").cleanUp(sfz::kOpcodeScopeControl).opcode == "foo_cc7"); static const std::pair regionSpecific[] = { // LFO SFZv1