mirror of
https://codeberg.org/armin/chromaflock.git
synced 2026-09-01 12:20:47 +02:00
Fix filter env: restore unipolar modulation so all env knobs are responsive
Reverts the sustain-relative modulation that made F.ENV SUS and the cutoff knob feel dead while a note was held. The envelope now modulates up from the base cutoff; at env amount 0 the cutoff equals the knob, and lowering env amount darkens the held tone as expected. Also extends the filter to 24/48 dB modes (extra TPT stages), adds the matching combobox options, gives knobs a real blurred drop shadow, and updates the AGENTS.md filterType choice count.
This commit is contained in:
parent
d4e738c9f1
commit
a1cd68b6b3
5 changed files with 38 additions and 18 deletions
|
|
@ -2,7 +2,8 @@
|
|||
#include <cmath>
|
||||
#include <algorithm>
|
||||
|
||||
enum class FilterType { LowPass12 = 0, LowPass24, BandPass, HighPass, Notch, NumTypes };
|
||||
enum class FilterType { LowPass12 = 0, LowPass24, BandPass, HighPass, Notch,
|
||||
BandPass24, HighPass24, Notch24, LowPass48, NumTypes };
|
||||
|
||||
class Filter {
|
||||
public:
|
||||
|
|
@ -12,7 +13,7 @@ public:
|
|||
}
|
||||
|
||||
void reset() {
|
||||
for (int i = 0; i < 4; ++i)
|
||||
for (int i = 0; i < 8; ++i)
|
||||
stage[i] = 0.0f;
|
||||
gCoeff = 0.0f;
|
||||
gTarget = 0.0f;
|
||||
|
|
@ -52,12 +53,30 @@ public:
|
|||
stage[2] = g * hp2 + bp2;
|
||||
stage[3] = g * bp2 + lp2;
|
||||
|
||||
// Stage 3 (fed by the stage-2 lowpass) — 36 dB
|
||||
float hp3 = (lp2 - (k + g) * stage[4] - stage[5]) / denom;
|
||||
float bp3 = g * hp3 + stage[4];
|
||||
float lp3 = g * bp3 + stage[5];
|
||||
stage[4] = g * hp3 + bp3;
|
||||
stage[5] = g * bp3 + lp3;
|
||||
|
||||
// Stage 4 (fed by the stage-3 lowpass) — 48 dB
|
||||
float hp4 = (lp3 - (k + g) * stage[6] - stage[7]) / denom;
|
||||
float bp4 = g * hp4 + stage[6];
|
||||
float lp4 = g * bp4 + stage[7];
|
||||
stage[6] = g * hp4 + bp4;
|
||||
stage[7] = g * bp4 + lp4;
|
||||
|
||||
switch (filterType) {
|
||||
case FilterType::LowPass12: return lp;
|
||||
case FilterType::LowPass24: return lp2;
|
||||
case FilterType::BandPass: return bp;
|
||||
case FilterType::HighPass: return hp;
|
||||
case FilterType::Notch: return input - bp;
|
||||
case FilterType::BandPass24: return bp2;
|
||||
case FilterType::HighPass24: return hp2;
|
||||
case FilterType::Notch24: return input - bp2;
|
||||
case FilterType::LowPass48: return lp4;
|
||||
case FilterType::NumTypes: return input;
|
||||
}
|
||||
return lp;
|
||||
|
|
@ -66,7 +85,7 @@ public:
|
|||
private:
|
||||
static constexpr float pi = 3.14159265358979323846f;
|
||||
double sampleRate = 44100.0;
|
||||
float stage[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
float stage[8] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f};
|
||||
|
||||
float gCoeff = 0.0f, gTarget = 0.0f;
|
||||
float kCoeff = 2.0f, kTarget = 2.0f;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue