Allow egN_ampeg and egN_amplitude both together
This commit is contained in:
parent
c30cad2534
commit
2d3f82331d
6 changed files with 20 additions and 14 deletions
|
|
@ -178,17 +178,14 @@ void sfz::Synth::buildRegion(const std::vector<Opcode>& regionOpcodes)
|
|||
parseOpcodes(regionOpcodes);
|
||||
|
||||
// Create the amplitude envelope
|
||||
if (!lastRegion->flexAmpEG) {
|
||||
if (!lastRegion->flexAmpEG)
|
||||
lastRegion->getOrCreateConnection(
|
||||
ModKey::createNXYZ(ModId::AmpEG, lastRegion->id),
|
||||
ModKey::createNXYZ(ModId::Amplitude, lastRegion->id)).sourceDepth = 100.0f;
|
||||
}
|
||||
else {
|
||||
ModKey source = ModKey::createNXYZ(ModId::Envelope, lastRegion->id, *lastRegion->flexAmpEG);
|
||||
ModKey target = ModKey::createNXYZ(ModId::Amplitude, lastRegion->id);
|
||||
if (!lastRegion->getConnection(source, target))
|
||||
lastRegion->getOrCreateConnection(source, target).sourceDepth = 100.0f;
|
||||
}
|
||||
ModKey::createNXYZ(ModId::MasterAmplitude, lastRegion->id)).sourceDepth = 1.0f;
|
||||
else
|
||||
lastRegion->getOrCreateConnection(
|
||||
ModKey::createNXYZ(ModId::Envelope, lastRegion->id, *lastRegion->flexAmpEG),
|
||||
ModKey::createNXYZ(ModId::MasterAmplitude, lastRegion->id)).sourceDepth = 1.0f;
|
||||
|
||||
if (octaveOffset != 0 || noteOffset != 0)
|
||||
lastRegion->offsetAllKeys(octaveOffset * 12 + noteOffset);
|
||||
|
|
|
|||
|
|
@ -380,14 +380,16 @@ void sfz::Voice::amplitudeEnvelope(absl::Span<float> modulationSpan) noexcept
|
|||
|
||||
ModMatrix& mm = resources.modMatrix;
|
||||
|
||||
// Amplitude EG
|
||||
absl::Span<const float> ampegOut(mm.getModulation(masterAmplitudeTarget), numSamples);
|
||||
ASSERT(ampegOut.data());
|
||||
copy(ampegOut, modulationSpan);
|
||||
|
||||
// Amplitude envelope
|
||||
applyGain1<float>(baseGain, modulationSpan);
|
||||
if (float* mod = mm.getModulation(amplitudeTarget)) {
|
||||
for (size_t i = 0; i < numSamples; ++i)
|
||||
modulationSpan[i] = normalizePercents(mod[i]);
|
||||
}
|
||||
else {
|
||||
ASSERTFALSE;
|
||||
modulationSpan[i] *= normalizePercents(mod[i]);
|
||||
}
|
||||
|
||||
// Volume envelope
|
||||
|
|
@ -1050,6 +1052,7 @@ void sfz::Voice::resetSmoothers() noexcept
|
|||
void sfz::Voice::saveModulationTargets(const Region* region) noexcept
|
||||
{
|
||||
ModMatrix& mm = resources.modMatrix;
|
||||
masterAmplitudeTarget = mm.findTarget(ModKey::createNXYZ(ModId::MasterAmplitude, region->getId()));
|
||||
amplitudeTarget = mm.findTarget(ModKey::createNXYZ(ModId::Amplitude, region->getId()));
|
||||
volumeTarget = mm.findTarget(ModKey::createNXYZ(ModId::Volume, region->getId()));
|
||||
panTarget = mm.findTarget(ModKey::createNXYZ(ModId::Pan, region->getId()));
|
||||
|
|
|
|||
|
|
@ -520,6 +520,7 @@ private:
|
|||
Smoother xfadeSmoother;
|
||||
void resetSmoothers() noexcept;
|
||||
|
||||
ModMatrix::TargetId masterAmplitudeTarget;
|
||||
ModMatrix::TargetId amplitudeTarget;
|
||||
ModMatrix::TargetId volumeTarget;
|
||||
ModMatrix::TargetId panTarget;
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ int ModIds::flags(ModId id) noexcept
|
|||
return kModIsPerVoice;
|
||||
|
||||
// targets
|
||||
case ModId::MasterAmplitude:
|
||||
return kModIsPerVoice|kModIsPercentMultiplicative;
|
||||
case ModId::Amplitude:
|
||||
return kModIsPerVoice|kModIsPercentMultiplicative;
|
||||
case ModId::Pan:
|
||||
|
|
|
|||
|
|
@ -34,7 +34,8 @@ enum class ModId : int {
|
|||
//--------------------------------------------------------------------------
|
||||
_TargetsStart = _SourcesEnd,
|
||||
|
||||
Amplitude = _TargetsStart,
|
||||
MasterAmplitude = _TargetsStart,
|
||||
Amplitude,
|
||||
Pan,
|
||||
Width,
|
||||
Position,
|
||||
|
|
|
|||
|
|
@ -81,6 +81,8 @@ std::string ModKey::toString() const
|
|||
case ModId::FilEG:
|
||||
return absl::StrCat("FilterEG {", region_.number(), "}");
|
||||
|
||||
case ModId::MasterAmplitude:
|
||||
return absl::StrCat("MasterAmplitude {", region_.number(), "}");
|
||||
case ModId::Amplitude:
|
||||
return absl::StrCat("Amplitude {", region_.number(), "}");
|
||||
case ModId::Pan:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue