mirror of
https://codeberg.org/armin/chromaflock.git
synced 2026-09-01 04:10:47 +02:00
Add distortion Symmetry and Tone knobs
This commit is contained in:
parent
2a1feaaea9
commit
1abf4f4b60
2 changed files with 21 additions and 5 deletions
|
|
@ -8,10 +8,12 @@ class Distortion {
|
|||
public:
|
||||
void prepare(double /*sr*/) {}
|
||||
|
||||
void setParameters(DistortionType type, float amount, float mix) {
|
||||
void setParameters(DistortionType type, float amount, float symmetry, float tone) {
|
||||
distType = type;
|
||||
distAmount = amount;
|
||||
dryWet = mix;
|
||||
distSymmetry = symmetry;
|
||||
distTone = tone;
|
||||
dryWet = 1.0f;
|
||||
}
|
||||
|
||||
float process(float input) {
|
||||
|
|
@ -58,7 +60,15 @@ public:
|
|||
break;
|
||||
}
|
||||
|
||||
if (distAmount < 0.001f)
|
||||
// Asymmetry: bias the signal before/after shaping for even-harmonic grit
|
||||
wet += distSymmetry * 0.5f;
|
||||
|
||||
// Tone: one-pole low-pass to tame harsh high harmonics
|
||||
float lpCoeff = distTone * 0.9f + 0.05f;
|
||||
toneState += lpCoeff * (wet - toneState);
|
||||
wet = toneState;
|
||||
|
||||
if (distAmount < 0.001f && std::abs(distSymmetry) < 0.001f)
|
||||
return input;
|
||||
|
||||
return input + (wet - input) * dryWet;
|
||||
|
|
@ -67,5 +77,8 @@ public:
|
|||
private:
|
||||
DistortionType distType = DistortionType::SoftClip;
|
||||
float distAmount = 0.0f;
|
||||
float dryWet = 0.0f;
|
||||
float distSymmetry = 0.0f;
|
||||
float distTone = 1.0f;
|
||||
float dryWet = 1.0f;
|
||||
float toneState = 0.0f;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue