AnalogTapeModel

Physical modelling signal processing for analog tape recording
Log | Files | Refs | Submodules | README | LICENSE

commit e72f08bdeebc629c9ea97587d104abfc83b3ee20
parent 1b30b66eb2757e0cdd3d669a6c02613de7a2d5cd
Author: jatinchowdhury18 <jatinchowdhury18@users.noreply.github.com>
Date:   Wed, 13 May 2020 11:05:41 -0700

Fix stability issues related to tanh approx and input range

Diffstat:
MPlugin/Source/Processors/Hysteresis/HysteresisProcessing.cpp | 6++----
MPlugin/Source/Processors/Hysteresis/HysteresisProcessor.cpp | 5+++++
2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/Plugin/Source/Processors/Hysteresis/HysteresisProcessing.cpp b/Plugin/Source/Processors/Hysteresis/HysteresisProcessing.cpp @@ -69,7 +69,7 @@ inline float HysteresisProcessing::deriv (float x_n, float x_n1, float x_d_n1) inline float HysteresisProcessing::hysteresisFunc (float M, float H, float H_d) { Q = (H + alpha * M) / a; - coth = 1.0f / dsp::FastMathApproximations::tanh (Q); + coth = 1.0f / std::tanh (Q); nearZero = Q < 0.001f && Q > -0.001f; M_diff = M_s * langevin (Q) - M; @@ -105,11 +105,9 @@ float HysteresisProcessing::process (float H) float M = M_n1 + k2; - if (std::isnan (M)) + if (std::isnan (M) || abs (M) > 20.0f) { M = 0.0f; - H = 0.0f; - H_d = 0.0f; } M_n1 = M; diff --git a/Plugin/Source/Processors/Hysteresis/HysteresisProcessor.cpp b/Plugin/Source/Processors/Hysteresis/HysteresisProcessor.cpp @@ -150,6 +150,11 @@ void HysteresisProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& fadeBuffer.copyFrom (ch, 0, buffer, ch, 0, buffer.getNumSamples()); } + // clip input to +9 dB + for (int ch = 0; ch < buffer.getNumChannels(); ++ch) + FloatVectorOperations::clip (buffer.getWritePointer (ch), + buffer.getWritePointer (ch), -8.0f, 8.0f, buffer.getNumSamples()); + dsp::AudioBlock<float> block (buffer); dsp::AudioBlock<float> osBlock;