Ampeg in modulation matrix
This commit is contained in:
parent
1212dbfbe9
commit
3412ead0ac
7 changed files with 32 additions and 7 deletions
|
|
@ -159,6 +159,11 @@ void sfz::Synth::buildRegion(const std::vector<Opcode>& regionOpcodes)
|
|||
ModKey::createCC(10, 1, defaultSmoothness, 100, 0),
|
||||
ModKey::createNXYZ(ModId::Pan, lastRegion->id)).sourceDepth = 1.0f;
|
||||
|
||||
// Create the amplitude envelope
|
||||
lastRegion->getOrCreateConnection(
|
||||
ModKey::createNXYZ(ModId::AmpEG, lastRegion->id),
|
||||
ModKey::createNXYZ(ModId::Amplitude, lastRegion->id)).sourceDepth = 100.0f;
|
||||
|
||||
//
|
||||
auto parseOpcodes = [&](const std::vector<Opcode>& opcodes) {
|
||||
for (auto& opcode : opcodes) {
|
||||
|
|
@ -1530,6 +1535,7 @@ void sfz::Synth::setupModMatrix()
|
|||
case ModId::Envelope:
|
||||
gen = genFlexEnvelope.get();
|
||||
break;
|
||||
case ModId::AmpEG:
|
||||
case ModId::PitchEG:
|
||||
case ModId::FilEG:
|
||||
gen = genADSREnvelope.get();
|
||||
|
|
|
|||
|
|
@ -130,7 +130,6 @@ void sfz::Voice::startVoice(Region* region, int delay, const TriggerEvent& event
|
|||
bendStepFactor = centsFactor(region->bendStep);
|
||||
bendSmoother.setSmoothing(region->bendSmooth, sampleRate);
|
||||
bendSmoother.reset(centsFactor(region->getBendInCents(resources.midiState.getPitchBend())));
|
||||
egAmplitude.reset(region->amplitudeEG, *region, resources.midiState, delay, triggerEvent.value, sampleRate);
|
||||
|
||||
resources.modMatrix.initVoice(id, region->getId(), delay);
|
||||
saveModulationTargets(region);
|
||||
|
|
@ -154,8 +153,6 @@ void sfz::Voice::release(int delay) noexcept
|
|||
|
||||
if (egAmplitude.getRemainingDelay() > delay) {
|
||||
switchState(State::cleanMeUp);
|
||||
} else {
|
||||
egAmplitude.startRelease(delay);
|
||||
}
|
||||
|
||||
resources.modMatrix.releaseVoice(id, region->getId(), delay);
|
||||
|
|
@ -367,14 +364,14 @@ void sfz::Voice::amplitudeEnvelope(absl::Span<float> modulationSpan) noexcept
|
|||
|
||||
ModMatrix& mm = resources.modMatrix;
|
||||
|
||||
// AmpEG envelope
|
||||
egAmplitude.getBlock(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]);
|
||||
modulationSpan[i] = normalizePercents(mod[i]);
|
||||
}
|
||||
else {
|
||||
ASSERTFALSE;
|
||||
}
|
||||
|
||||
// Volume envelope
|
||||
|
|
|
|||
|
|
@ -336,6 +336,10 @@ public:
|
|||
Duration getLastFilterDuration() const noexcept { return filterDuration; }
|
||||
Duration getLastPanningDuration() const noexcept { return panningDuration; }
|
||||
|
||||
/**
|
||||
* @brief Get the SFZv1 amplitude EG, if existing
|
||||
*/
|
||||
ADSREnvelope<float>* getAmplitudeEG() { return &egAmplitude; }
|
||||
/**
|
||||
* @brief Get the SFZv1 pitch EG, if existing
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ int ModIds::flags(ModId id) noexcept
|
|||
return kModIsPerVoice;
|
||||
case ModId::LFO:
|
||||
return kModIsPerVoice;
|
||||
case ModId::AmpEG:
|
||||
return kModIsPerVoice;
|
||||
case ModId::PitchEG:
|
||||
return kModIsPerVoice;
|
||||
case ModId::FilEG:
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ enum class ModId : int {
|
|||
Controller = _SourcesStart,
|
||||
Envelope,
|
||||
LFO,
|
||||
AmpEG,
|
||||
PitchEG,
|
||||
FilEG,
|
||||
|
||||
|
|
|
|||
|
|
@ -74,6 +74,8 @@ std::string ModKey::toString() const
|
|||
return absl::StrCat("EG ", 1 + params_.N, " {", region_.number(), "}");
|
||||
case ModId::LFO:
|
||||
return absl::StrCat("LFO ", 1 + params_.N, " {", region_.number(), "}");
|
||||
case ModId::AmpEG:
|
||||
return absl::StrCat("AmplitudeEG {", region_.number(), "}");
|
||||
case ModId::PitchEG:
|
||||
return absl::StrCat("PitchEG {", region_.number(), "}");
|
||||
case ModId::FilEG:
|
||||
|
|
|
|||
|
|
@ -35,6 +35,11 @@ void ADSREnvelopeSource::init(const ModKey& sourceKey, NumericId<Voice> voiceId,
|
|||
const EGDescription* desc = nullptr;
|
||||
|
||||
switch (sourceKey.id()) {
|
||||
case ModId::AmpEG:
|
||||
eg = voice->getAmplitudeEG();
|
||||
ASSERT(eg);
|
||||
desc = ®ion->amplitudeEG;
|
||||
break;
|
||||
case ModId::PitchEG:
|
||||
eg = voice->getPitchEG();
|
||||
ASSERT(eg);
|
||||
|
|
@ -69,6 +74,10 @@ void ADSREnvelopeSource::release(const ModKey& sourceKey, NumericId<Voice> voice
|
|||
ADSREnvelope<float>* eg = nullptr;
|
||||
|
||||
switch (sourceKey.id()) {
|
||||
case ModId::AmpEG:
|
||||
eg = voice->getAmplitudeEG();
|
||||
ASSERT(eg);
|
||||
break;
|
||||
case ModId::PitchEG:
|
||||
eg = voice->getPitchEG();
|
||||
ASSERT(eg);
|
||||
|
|
@ -98,6 +107,10 @@ void ADSREnvelopeSource::generate(const ModKey& sourceKey, NumericId<Voice> voic
|
|||
ADSREnvelope<float>* eg = nullptr;
|
||||
|
||||
switch (sourceKey.id()) {
|
||||
case ModId::AmpEG:
|
||||
eg = voice->getAmplitudeEG();
|
||||
ASSERT(eg);
|
||||
break;
|
||||
case ModId::PitchEG:
|
||||
eg = voice->getPitchEG();
|
||||
ASSERT(eg);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue