Fix filter env: modulate relative to sustain so cutoff knob stays audible at any env amount

This commit is contained in:
Armin 2026-08-13 13:37:39 +02:00
commit d4e738c9f1

View file

@ -128,8 +128,14 @@ public:
left *= noteVelocity * envSample; left *= noteVelocity * envSample;
right *= noteVelocity * envSample; right *= noteVelocity * envSample;
// Filter cutoff with env + keytrack // Filter cutoff with env + keytrack.
float modCutoff = filterCutoff * std::pow(2.0f, fEnvSample * filterEnvAmount * 4.0f); // Modulate RELATIVE to the envelope's sustain level so the held
// (sustain) cutoff always equals the base cutoff knob regardless of
// env amount — the envelope only opens above (attack) and closes
// below (release) that centre. This keeps the cutoff knob audible
// at any env amount instead of collapsing when env amt is lowered.
float modCutoff = filterCutoff * std::pow(2.0f,
(fEnvSample - filterEnvSustain) * filterEnvAmount * 4.0f);
float keyTrackFactor = std::pow(2.0f, (static_cast<float>(currentMidiNote) - 60.0f) / 12.0f * keyTrack); float keyTrackFactor = std::pow(2.0f, (static_cast<float>(currentMidiNote) - 60.0f) / 12.0f * keyTrack);
modCutoff *= keyTrackFactor; modCutoff *= keyTrackFactor;
@ -191,6 +197,7 @@ public:
filterResonance = res; filterResonance = res;
filterType = ft; filterType = ft;
filterEnvAmount = fEnvAmt; filterEnvAmount = fEnvAmt;
filterEnvSustain = fSus;
keyTrack = kTrack; keyTrack = kTrack;
pan = p; pan = p;
drive = std::max(drv, 1.001f); drive = std::max(drv, 1.001f);
@ -245,6 +252,7 @@ private:
float filterResonance = 0.7f; float filterResonance = 0.7f;
FilterType filterType = FilterType::LowPass12; FilterType filterType = FilterType::LowPass12;
float filterEnvAmount = 0.0f; float filterEnvAmount = 0.0f;
float filterEnvSustain = 0.5f;
float keyTrack = 0.5f; float keyTrack = 0.5f;
float pan = 0.0f; float pan = 0.0f;
float drive = 1.5f; float drive = 1.5f;