Implement some oncc for LFOv2

This commit is contained in:
Jean Pierre Cimalando 2021-04-01 02:49:01 +02:00
parent de7d47a9f1
commit ea7bb1cf6c
4 changed files with 67 additions and 36 deletions

View file

@ -1161,6 +1161,19 @@ bool sfz::Region::parseLFOOpcodeV2(const Opcode& opcode)
return nullptr; return nullptr;
return &lfo.sub[subNumber1Based - 1]; return &lfo.sub[subNumber1Based - 1];
}; };
auto LFO_target = [this, &opcode, lfoNumber](ModId targetId, ModId depthId, const OpcodeSpec<float>& spec) -> bool {
const ModKey source = ModKey::createNXYZ(ModId::LFO, id, lfoNumber);
const ModKey target = ModKey::createNXYZ(targetId, id);
Connection& conn = getOrCreateConnection(source, target);
if (depthId == ModId::Undefined)
conn.sourceDepth = opcode.read(spec);
else {
const ModKey depth = ModKey::createNXYZ(depthId, id, lfoNumber);
conn.sourceDepthMod = depth;
processGenericCc(opcode, spec, depth);
}
return true;
};
auto LFO_EG_filter_EQ_target = [this, &opcode, lfoNumber](ModId sourceId, ModId targetId, const OpcodeSpec<float>& spec) -> bool { auto LFO_EG_filter_EQ_target = [this, &opcode, lfoNumber](ModId sourceId, ModId targetId, const OpcodeSpec<float>& spec) -> bool {
const unsigned index = opcode.parameters.size() == 2 ? opcode.parameters.back() - 1 : 0; const unsigned index = opcode.parameters.size() == 2 ? opcode.parameters.back() - 1 : 0;
if (!extendIfNecessary(filters, index + 1, Default::numFilters)) if (!extendIfNecessary(filters, index + 1, Default::numFilters))
@ -1252,52 +1265,40 @@ bool sfz::Region::parseLFOOpcodeV2(const Opcode& opcode)
// Modulation: LFO (targets) // Modulation: LFO (targets)
case hash("lfo&_amplitude"): case hash("lfo&_amplitude"):
{ LFO_target(ModId::Amplitude, {}, Default::amplitudeMod);
const ModKey source = ModKey::createNXYZ(ModId::LFO, id, lfoNumber); break;
const ModKey target = ModKey::createNXYZ(ModId::Amplitude, id); case_any_ccN("lfo&_amplitude"):
getOrCreateConnection(source, target).sourceDepth = LFO_target(ModId::Amplitude, ModId::LFOAmplitudeDepth, Default::amplitudeMod);
opcode.read(Default::amplitudeMod);
}
break; break;
case hash("lfo&_pan"): case hash("lfo&_pan"):
{ LFO_target(ModId::Pan, {}, Default::panMod);
const ModKey source = ModKey::createNXYZ(ModId::LFO, id, lfoNumber); break;
const ModKey target = ModKey::createNXYZ(ModId::Pan, id); case_any_ccN("lfo&_pan"):
getOrCreateConnection(source, target).sourceDepth = LFO_target(ModId::Pan, ModId::LFOPanDepth, Default::panMod);
opcode.read(Default::panMod);
}
break; break;
case hash("lfo&_width"): case hash("lfo&_width"):
{ LFO_target(ModId::Width, {}, Default::widthMod);
const ModKey source = ModKey::createNXYZ(ModId::LFO, id, lfoNumber); break;
const ModKey target = ModKey::createNXYZ(ModId::Width, id); case_any_ccN("lfo&_width"):
getOrCreateConnection(source, target).sourceDepth = LFO_target(ModId::Width, ModId::LFOWidthDepth, Default::widthMod);
opcode.read(Default::widthMod);
}
break; break;
case hash("lfo&_position"): // sfizz extension case hash("lfo&_position"): // sfizz extension
{ LFO_target(ModId::Position, {}, Default::positionMod);
const ModKey source = ModKey::createNXYZ(ModId::LFO, id, lfoNumber); break;
const ModKey target = ModKey::createNXYZ(ModId::Position, id); case_any_ccN("lfo&_position"): // sfizz extension
getOrCreateConnection(source, target).sourceDepth = LFO_target(ModId::Position, ModId::LFOPositionDepth, Default::positionMod);
opcode.read(Default::positionMod);
}
break; break;
case hash("lfo&_pitch"): case hash("lfo&_pitch"):
{ LFO_target(ModId::Pitch, {}, Default::pitchMod);
const ModKey source = ModKey::createNXYZ(ModId::LFO, id, lfoNumber); break;
const ModKey target = ModKey::createNXYZ(ModId::Pitch, id); case_any_ccN("lfo&_pitch"):
getOrCreateConnection(source, target).sourceDepth = LFO_target(ModId::Pitch, ModId::LFOPitchDepth, Default::pitchMod);
opcode.read(Default::pitchMod);
}
break; break;
case hash("lfo&_volume"): case hash("lfo&_volume"):
{ LFO_target(ModId::Volume, {}, Default::volumeMod);
const ModKey source = ModKey::createNXYZ(ModId::LFO, id, lfoNumber); break;
const ModKey target = ModKey::createNXYZ(ModId::Volume, id); case_any_ccN("lfo&_volume"):
getOrCreateConnection(source, target).sourceDepth = LFO_target(ModId::Volume, ModId::LFOVolumeDepth, Default::volumeMod);
opcode.read(Default::volumeMod);
}
break; break;
case hash("lfo&_cutoff&"): case hash("lfo&_cutoff&"):

View file

@ -100,6 +100,18 @@ int ModIds::flags(ModId id) noexcept
return kModIsPerVoice|kModIsAdditive; return kModIsPerVoice|kModIsAdditive;
case ModId::LFOPhase: case ModId::LFOPhase:
return kModIsPerVoice|kModIsAdditive; return kModIsPerVoice|kModIsAdditive;
case ModId::LFOAmplitudeDepth:
return kModIsPerVoice|kModIsMultiplicative;
case ModId::LFOPanDepth:
return kModIsPerVoice|kModIsAdditive;
case ModId::LFOWidthDepth:
return kModIsPerVoice|kModIsAdditive;
case ModId::LFOPositionDepth:
return kModIsPerVoice|kModIsAdditive;
case ModId::LFOPitchDepth:
return kModIsPerVoice|kModIsAdditive;
case ModId::LFOVolumeDepth:
return kModIsPerVoice|kModIsAdditive;
// unknown // unknown
default: default:

View file

@ -64,6 +64,12 @@ enum class ModId : int {
LFOFrequency, LFOFrequency,
LFOBeats, LFOBeats,
LFOPhase, LFOPhase,
LFOAmplitudeDepth,
LFOPanDepth,
LFOWidthDepth,
LFOPositionDepth,
LFOPitchDepth,
LFOVolumeDepth,
_TargetsEnd, _TargetsEnd,
// [/targets] -------------------------------------------------------------- // [/targets] --------------------------------------------------------------

View file

@ -170,6 +170,18 @@ std::string ModKey::toString() const
return absl::StrCat("LFOBeats {", region_.number(), ", N=", 1 + params_.N, "}"); return absl::StrCat("LFOBeats {", region_.number(), ", N=", 1 + params_.N, "}");
case ModId::LFOPhase: case ModId::LFOPhase:
return absl::StrCat("LFOPhase {", region_.number(), ", N=", 1 + params_.N, "}"); return absl::StrCat("LFOPhase {", region_.number(), ", N=", 1 + params_.N, "}");
case ModId::LFOAmplitudeDepth:
return absl::StrCat("LFOAmplitudeDepth {", region_.number(), ", N=", 1 + params_.N, "}");
case ModId::LFOPanDepth:
return absl::StrCat("LFOPanDepth {", region_.number(), ", N=", 1 + params_.N, "}");
case ModId::LFOWidthDepth:
return absl::StrCat("LFOWidthDepth {", region_.number(), ", N=", 1 + params_.N, "}");
case ModId::LFOPositionDepth:
return absl::StrCat("LFOPositionDepth {", region_.number(), ", N=", 1 + params_.N, "}");
case ModId::LFOPitchDepth:
return absl::StrCat("LFOPitchDepth {", region_.number(), ", N=", 1 + params_.N, "}");
case ModId::LFOVolumeDepth:
return absl::StrCat("LFOVolumeDepth {", region_.number(), ", N=", 1 + params_.N, "}");
default: default:
return {}; return {};