Opcode cleanups for <control> and set_realccN
This commit is contained in:
parent
8136874552
commit
e666b1dfaa
4 changed files with 38 additions and 7 deletions
|
|
@ -42,6 +42,8 @@ enum OpcodeCategory {
|
|||
enum OpcodeScope {
|
||||
//! unknown scope or other
|
||||
kOpcodeScopeGeneric,
|
||||
//! control scope
|
||||
kOpcodeScopeControl,
|
||||
//! region scope
|
||||
kOpcodeScopeRegion,
|
||||
//! effect scope
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -199,7 +199,9 @@ void sfz::Synth::handleGroupOpcodes(const std::vector<Opcode>& members, const st
|
|||
|
||||
void sfz::Synth::handleControlOpcodes(const std::vector<Opcode>& 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<Opcode>& 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)
|
||||
|
|
|
|||
|
|
@ -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<absl::string_view, absl::string_view> regionSpecific[] = {
|
||||
// LFO SFZv1
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue