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 &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 {
const unsigned index = opcode.parameters.size() == 2 ? opcode.parameters.back() - 1 : 0;
if (!extendIfNecessary(filters, index + 1, Default::numFilters))
@ -1252,52 +1265,40 @@ bool sfz::Region::parseLFOOpcodeV2(const Opcode& opcode)
// Modulation: LFO (targets)
case hash("lfo&_amplitude"):
{
const ModKey source = ModKey::createNXYZ(ModId::LFO, id, lfoNumber);
const ModKey target = ModKey::createNXYZ(ModId::Amplitude, id);
getOrCreateConnection(source, target).sourceDepth =
opcode.read(Default::amplitudeMod);
}
LFO_target(ModId::Amplitude, {}, Default::amplitudeMod);
break;
case_any_ccN("lfo&_amplitude"):
LFO_target(ModId::Amplitude, ModId::LFOAmplitudeDepth, Default::amplitudeMod);
break;
case hash("lfo&_pan"):
{
const ModKey source = ModKey::createNXYZ(ModId::LFO, id, lfoNumber);
const ModKey target = ModKey::createNXYZ(ModId::Pan, id);
getOrCreateConnection(source, target).sourceDepth =
opcode.read(Default::panMod);
}
LFO_target(ModId::Pan, {}, Default::panMod);
break;
case_any_ccN("lfo&_pan"):
LFO_target(ModId::Pan, ModId::LFOPanDepth, Default::panMod);
break;
case hash("lfo&_width"):
{
const ModKey source = ModKey::createNXYZ(ModId::LFO, id, lfoNumber);
const ModKey target = ModKey::createNXYZ(ModId::Width, id);
getOrCreateConnection(source, target).sourceDepth =
opcode.read(Default::widthMod);
}
LFO_target(ModId::Width, {}, Default::widthMod);
break;
case_any_ccN("lfo&_width"):
LFO_target(ModId::Width, ModId::LFOWidthDepth, Default::widthMod);
break;
case hash("lfo&_position"): // sfizz extension
{
const ModKey source = ModKey::createNXYZ(ModId::LFO, id, lfoNumber);
const ModKey target = ModKey::createNXYZ(ModId::Position, id);
getOrCreateConnection(source, target).sourceDepth =
opcode.read(Default::positionMod);
}
LFO_target(ModId::Position, {}, Default::positionMod);
break;
case_any_ccN("lfo&_position"): // sfizz extension
LFO_target(ModId::Position, ModId::LFOPositionDepth, Default::positionMod);
break;
case hash("lfo&_pitch"):
{
const ModKey source = ModKey::createNXYZ(ModId::LFO, id, lfoNumber);
const ModKey target = ModKey::createNXYZ(ModId::Pitch, id);
getOrCreateConnection(source, target).sourceDepth =
opcode.read(Default::pitchMod);
}
LFO_target(ModId::Pitch, {}, Default::pitchMod);
break;
case_any_ccN("lfo&_pitch"):
LFO_target(ModId::Pitch, ModId::LFOPitchDepth, Default::pitchMod);
break;
case hash("lfo&_volume"):
{
const ModKey source = ModKey::createNXYZ(ModId::LFO, id, lfoNumber);
const ModKey target = ModKey::createNXYZ(ModId::Volume, id);
getOrCreateConnection(source, target).sourceDepth =
opcode.read(Default::volumeMod);
}
LFO_target(ModId::Volume, {}, Default::volumeMod);
break;
case_any_ccN("lfo&_volume"):
LFO_target(ModId::Volume, ModId::LFOVolumeDepth, Default::volumeMod);
break;
case hash("lfo&_cutoff&"):

View file

@ -100,6 +100,18 @@ int ModIds::flags(ModId id) noexcept
return kModIsPerVoice|kModIsAdditive;
case ModId::LFOPhase:
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
default:

View file

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

View file

@ -170,6 +170,18 @@ std::string ModKey::toString() const
return absl::StrCat("LFOBeats {", region_.number(), ", N=", 1 + params_.N, "}");
case ModId::LFOPhase:
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:
return {};