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