commit 704824feb90e36400d65d5bd100769958d773c72
parent a8d5bfc406714f6fed22d42e43bafaf689c9b408
Author: jatinchowdhury18 <[email protected]>
Date: Sun, 27 Sep 2020 17:03:22 -0700
Improve internal clipping characteristics for hysteresis processing
Diffstat:
4 files changed, 31 insertions(+), 7 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
@@ -7,6 +7,7 @@ this file.
- Added "mix groups" to allow instances of the plugin to be synced across a mix.
- Added Chew variance parameter to control the randomness of the chew dropouts.
- Improved behavior for thickness slider.
+- Improved internal clipping characteristic (to preserve stability).
- Improved DC blocker for hysteresis processor.
## [2.5.0] - 2020-08-23
diff --git a/Plugin/Source/Processors/Hysteresis/HysteresisProcessing.h b/Plugin/Source/Processors/Hysteresis/HysteresisProcessing.h
@@ -33,10 +33,15 @@ public:
double H_d = deriv (H, H_n1, H_d_n1);
double M = (this->*solver) (H, H_d);
- if (std::isnan (M) || M > upperLim)
- {
- M = 0.0;
- }
+ // check for instability
+ bool illCondition = std::isnan (M) || M > upperLim;
+ M = illCondition ? 0.0 : M;
+ H_d = illCondition ? 0.0 : H_d;
+
+ // if (std::isnan (M) || M > upperLim)
+ // {
+ // M = 0.0;
+ // }
M_n1 = M;
H_n1 = H;
@@ -51,7 +56,7 @@ private:
inline double langevinD2 (double x) const noexcept; // 2nd derivative of Langevin function
inline double deriv (double x_n, double x_n1, double x_d_n1) const noexcept // Derivative by alpha transform
{
- constexpr double dAlpha = 0.9;
+ constexpr double dAlpha = 0.75;
return (((1.0 + dAlpha) / T) * (x_n - x_n1)) - dAlpha * x_d_n1;
}
diff --git a/Plugin/Source/Processors/Hysteresis/HysteresisProcessor.cpp b/Plugin/Source/Processors/Hysteresis/HysteresisProcessor.cpp
@@ -50,6 +50,23 @@ void HysteresisProcessor::setSolver (int newSolver)
for (int ch = 0; ch < 2; ++ch)
hProcs[ch].setSolver (static_cast<SolverType> (newSolver));
+
+ // set clip level for solver
+ switch (newSolver)
+ {
+ case 0: // RK2
+ case 1: // RK4
+ clipLevel = 10.0f;
+ return;
+
+ case 2: // NR4
+ case 3: // NR8
+ clipLevel = 12.5f;
+ return;
+
+ default:
+ clipLevel = 20.0f;
+ };
}
float HysteresisProcessor::calcMakeup()
@@ -166,10 +183,10 @@ void HysteresisProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer&
wasV1 = useV1;
- // clip input to +9 dB
+ // clip input to avoid unstable hysteresis
for (int ch = 0; ch < buffer.getNumChannels(); ++ch)
FloatVectorOperations::clip (buffer.getWritePointer (ch),
- buffer.getWritePointer (ch), -8.0f, 8.0f, buffer.getNumSamples());
+ buffer.getWritePointer (ch), -clipLevel, clipLevel, buffer.getNumSamples());
dsp::AudioBlock<float> block (buffer);
dsp::AudioBlock<float> osBlock = overSample[curOS]->processSamplesUp (block);
diff --git a/Plugin/Source/Processors/Hysteresis/HysteresisProcessor.h b/Plugin/Source/Processors/Hysteresis/HysteresisProcessor.h
@@ -62,6 +62,7 @@ private:
float biasFreq = 48000.0f;
float biasAngle[2];
bool wasV1 = false, useV1 = false;
+ float clipLevel = 20.0f;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (HysteresisProcessor)
};