From 1abf4f4b600d6a9ed95e8bed404f531ab033966a Mon Sep 17 00:00:00 2001 From: Armin Date: Wed, 15 Jul 2026 23:51:38 +0200 Subject: [PATCH] Add distortion Symmetry and Tone knobs --- Source/DSP/Distortion.h | 21 +++++++++++++++++---- Source/PluginProcessor.cpp | 5 ++++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Source/DSP/Distortion.h b/Source/DSP/Distortion.h index 06d7425..763be02 100644 --- a/Source/DSP/Distortion.h +++ b/Source/DSP/Distortion.h @@ -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; }; diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 97684ff..e9432d5 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -43,6 +43,7 @@ juce::AudioProcessorValueTreeState::ParameterLayout ChromaFlockProcessor::create juce::AudioProcessorValueTreeState::ParameterLayout layout; auto zeroOne = juce::NormalisableRange(0.0f, 1.0f, 0.01f); + auto minusOneOne = juce::NormalisableRange(-1.0f, 1.0f, 0.01f); // LFO1 depth: fine 0.001 step, with a skew of 2.0 (value = p^2) so the // lower knob range resolves much finer and the 0.001 step only applies @@ -153,7 +154,9 @@ juce::AudioProcessorValueTreeState::ParameterLayout ChromaFlockProcessor::create layout.add(std::make_unique( juce::ParameterID{"distAmount", 1}, "Dist Amount", zeroOne, 0.0f)); layout.add(std::make_unique( - juce::ParameterID{"distMix", 1}, "Dist Mix", zeroOne, 0.0f)); + juce::ParameterID{"distSymmetry", 1}, "Dist Symmetry", minusOneOne, 0.0f)); + layout.add(std::make_unique( + juce::ParameterID{"distTone", 1}, "Dist Tone", zeroOne, 1.0f)); // COMPRESSOR layout.add(std::make_unique(