AnalogTapeModel

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

commit c2fa1c5a477d74916c95674ac450f0ed96c917b7
parent b5f38990ed07d2e751149ad7b6d2e5adbe148a27
Author: jatinchowdhury18 <jatinchowdhury18@gmail.com>
Date:   Mon, 16 Aug 2021 02:03:14 -0700

Fix clang-tidy issues and add workflow (#211)

* Fix clang-tidy issues and add workflow

* Apply clang-format

* Fix clang-tidy failures

* Apply clang-format

Co-authored-by: jatinchowdhury18 <jatinchowdhury18@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Diffstat:
A.clang-tidy | 38++++++++++++++++++++++++++++++++++++++
A.github/workflows/clang-tidy.yml | 46++++++++++++++++++++++++++++++++++++++++++++++
M.gitignore | 2+-
MPlugin/Source/GUI/MyLNF.cpp | 4++--
MPlugin/Source/GUI/OnOff/OnOffManager.cpp | 2+-
MPlugin/Source/Headless/UnitTests/HysteresisOpsTest.cpp | 22+++++++++++-----------
MPlugin/Source/Headless/UnitTests/SpeedTest.cpp | 8++++----
MPlugin/Source/MixGroups/MixGroupsController.h | 2+-
MPlugin/Source/Presets/PresetComp.h | 2+-
MPlugin/Source/Presets/PresetManager.cpp | 2+-
MPlugin/Source/Processors/BypassProcessor.h | 8++++----
MPlugin/Source/Processors/Chew/Dropout.h | 7+------
MPlugin/Source/Processors/Hysteresis/DCBlocker.h | 3++-
MPlugin/Source/Processors/Hysteresis/HysteresisOps.h | 26+++++++++++++-------------
MPlugin/Source/Processors/Hysteresis/HysteresisProcessing.cpp | 2+-
MPlugin/Source/Processors/Hysteresis/HysteresisProcessing.h | 102++++++++++++++++++++++++++++++++++++++++++-------------------------------------
MPlugin/Source/Processors/Hysteresis/HysteresisProcessor.cpp | 98++++++++++++++++++++++++++++++++++++++++----------------------------------------
MPlugin/Source/Processors/Hysteresis/HysteresisSTN.cpp | 4++--
MPlugin/Source/Processors/Loss_Effects/AzimuthProc.cpp | 6+++---
19 files changed, 235 insertions(+), 149 deletions(-)

diff --git a/.clang-tidy b/.clang-tidy @@ -0,0 +1,38 @@ +Checks: "-*,\ +cppcoreguidelines-*,\ +modernize-*,\ +portability-*,\ +readability-*,\ +-cppcoreguidelines-avoid-c-arrays,\ +-cppcoreguidelines-pro-type-union-access,\ +-cppcoreguidelines-owning-memory,\ +-cppcoreguidelines-macro-usage,\ +-cppcoreguidelines-pro-type-vararg,\ +-cppcoreguidelines-avoid-magic-numbers,\ +-cppcoreguidelines-pro-bounds-pointer-arithmetic,\ +-modernize-avoid-c-arrays,\ +-modernize-loop-convert,\ +-modernize-use-equals-default,\ +-modernize-use-trailing-return-type,\ +-readability-avoid-const-params-in-decls,\ +-readability-convert-member-functions-to-static,\ +-readability-magic-numbers,\ +-readability-uppercase-literal-suffix,\ +-readability-const-return-type,\ +-readability-named-parameter,\ +-readability-make-member-function-const,\ +-cppcoreguidelines-avoid-non-const-global-variables,\ +-cppcoreguidelines-init-variables,\ +-cppcoreguidelines-pro-type-member-init,\ +-cppcoreguidelines-special-member-functions,\ +-cppcoreguidelines-pro-bounds-constant-array-index,\ +-cppcoreguidelines-non-private-member-variables-in-classes +" +WarningsAsErrors: '-*' +HeaderFilterRegex: '.*' +FormatStyle: none +User: jatinchowdhury18 +CheckOptions: + - key: readability-braces-around-statements.ShortStatementLines + value: '2' +... diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml @@ -0,0 +1,46 @@ +name: clang-tidy + +on: + pull_request: + branches: + - main + - develop + paths: + - '**.cpp' + - '**.h' + + workflow_dispatch: + +jobs: + build_and_test: + if: contains(toJson(github.event.commits), '***NO_CI***') == false && contains(toJson(github.event.commits), '[ci skip]') == false && contains(toJson(github.event.commits), '[skip ci]') == false + name: Apply clang-format to pull request + runs-on: ubuntu-latest + + steps: + - name: Install Linux Deps + if: runner.os == 'Linux' + run: | + sudo apt-get update + sudo apt install clang-tidy + + - name: Checkout code + uses: actions/checkout@v2 + with: + persist-credentials: false + fetch-depth: 0 + + - name: Run clang-tidy + shell: bash + run: find Plugin/Source -iname *.cpp | xargs clang-tidy > tidy_log.txt && status=0 || status=1 + + - name: Check results + shell: bash + run: | + num_failures=$(grep "" -c tidy_log.txt) + num_ignore=$(echo $(($(grep "file not found" -c tidy_log.txt)*3))) + num_actual=$(($num_failures - $num_ignore)) + if [ "$num_actual" -gt 1 ]; then + more tidy_log.txt + exit 1 + fi diff --git a/.gitignore b/.gitignore @@ -38,4 +38,4 @@ bin/*[!.zip] *.exe *_Packaged *.dmg - +*log* diff --git a/Plugin/Source/GUI/MyLNF.cpp b/Plugin/Source/GUI/MyLNF.cpp @@ -23,8 +23,8 @@ void MyLNF::drawRotarySlider (juce::Graphics& g, int x, int y, int width, int he return; juce::Point<float> centre (x + std::floor (width * 0.5f + 0.5f), y + std::floor (height * 0.5f + 0.5f)); - diameter -= (diameter % 2) ? 9 : 8; - float radius = diameter * 0.5f; + diameter -= (diameter % 2 == 1) ? 9 : 8; + float radius = (float) diameter * 0.5f; x = int (centre.x - radius); y = int (centre.y - radius); diff --git a/Plugin/Source/GUI/OnOff/OnOffManager.cpp b/Plugin/Source/GUI/OnOff/OnOffManager.cpp @@ -3,7 +3,7 @@ namespace { -static const std::unordered_map<String, StringArray> triggerMap { +const std::unordered_map<String, StringArray> triggerMap { { String ("ifilt_onoff"), StringArray ({ "Low Cut", "High Cut", "Makeup" }) }, { String ("hyst_onoff"), StringArray ({ "Bias", "Saturation", "Drive" }) }, { String ("tone_onoff"), StringArray ({ "Bass", "Treble", "Transition Frequency" }) }, diff --git a/Plugin/Source/Headless/UnitTests/HysteresisOpsTest.cpp b/Plugin/Source/Headless/UnitTests/HysteresisOpsTest.cpp @@ -67,17 +67,17 @@ public: hProc.cook (0.5, 0.5, 0.5, false); #if HYSTERESIS_USE_SIMD - for (int n = 0; n < 10; ++n) - { - x[n] = hProc.process<SolverType::NR4> ((Vec2) (x[n] * 0.001)).get (0); - expectWithinAbsoluteError (x[n], y[n], 1.0e-6); - } + for (int n = 0; n < 10; ++n) + { + x[n] = hProc.process<SolverType::NR4> ((Vec2) (x[n] * 0.001)).get (0); + expectWithinAbsoluteError (x[n], y[n], 1.0e-6); + } #else - for (int n = 0; n < 10; ++n) - x[n] = hProc.process<SolverType::NR4> (x[n] * 0.001); - - std::copy(x, x + 10, std::ostream_iterator<double>(std::cout, ", ")); - std::cout << std::endl; + for (int n = 0; n < 10; ++n) + x[n] = hProc.process<SolverType::NR4> (x[n] * 0.001); + + std::copy (x, x + 10, std::ostream_iterator<double> (std::cout, ", ")); + std::cout << std::endl; #endif } @@ -85,7 +85,7 @@ public: { beginTest ("Langevin Test"); testLangevin(); - + beginTest ("Sign Ops Test"); testSignOps(); diff --git a/Plugin/Source/Headless/UnitTests/SpeedTest.cpp b/Plugin/Source/Headless/UnitTests/SpeedTest.cpp @@ -39,12 +39,12 @@ public: auto duration = (end - start) / 1000.0f; logMessage ("Plugin processing time: " + String (duration) + " seconds"); - - #if JUCE_WINDOWS + +#if JUCE_WINDOWS expectLessThan (duration, 1.0, "Plugin is not fast enough!"); - #else +#else expectLessThan (duration, 5.0, "Plugin is not fast enough!"); - #endif +#endif } }; diff --git a/Plugin/Source/MixGroups/MixGroupsController.h b/Plugin/Source/MixGroups/MixGroupsController.h @@ -15,7 +15,7 @@ class MixGroupsController : private AudioProcessorValueTreeState::Listener, { public: MixGroupsController (AudioProcessorValueTreeState& vts, AudioProcessor* proc); - ~MixGroupsController(); + ~MixGroupsController() override; static void createParameterLayout (std::vector<std::unique_ptr<RangedAudioParameter>>& params); diff --git a/Plugin/Source/Presets/PresetComp.h b/Plugin/Source/Presets/PresetComp.h @@ -15,7 +15,7 @@ public: }; PresetComp (ChowtapeModelAudioProcessor& proc, PresetManager& manager); - ~PresetComp(); + ~PresetComp() override; void paint (Graphics& g) override; void resized() override; diff --git a/Plugin/Source/Presets/PresetManager.cpp b/Plugin/Source/Presets/PresetManager.cpp @@ -4,7 +4,7 @@ namespace { -static String userPresetPath = "ChowdhuryDSP/ChowTape/UserPresets.txt"; +const String userPresetPath = "ChowdhuryDSP/ChowTape/UserPresets.txt"; } Preset::Preset (String presetFile) diff --git a/Plugin/Source/Processors/BypassProcessor.h b/Plugin/Source/Processors/BypassProcessor.h @@ -27,8 +27,8 @@ public: */ bool processBlockIn (AudioBuffer<float>& block, bool onOffParam) { - if (onOffParam == false && prevOnOffParam == false) - return false; + if (! onOffParam && ! prevOnOffParam) + return false; // NOLINT if (onOffParam != prevOnOffParam) fadeBuffer.makeCopyOf (block, true); @@ -44,8 +44,8 @@ public: const auto numChannels = block.getNumChannels(); const auto numSamples = block.getNumSamples(); - float startGain = onOffParam == false ? 1.0f // fade out - : 0.0f; // fade in + float startGain = ! onOffParam ? 1.0f // fade out + : 0.0f; // fade in float endGain = 1.0f - startGain; block.applyGainRamp (0, numSamples, startGain, endGain); diff --git a/Plugin/Source/Processors/Chew/Dropout.h b/Plugin/Source/Processors/Chew/Dropout.h @@ -50,12 +50,7 @@ public: inline float dropout (float x, int ch) { - float sign = 0.0f; - if (x > 0.0f) - sign = 1.0f; - else if (x < 0.0f) - sign = -1.0f; - + auto sign = (float) chowdsp::signum (x); return pow (abs (x), powerSmooth[ch].getNextValue()) * sign; } diff --git a/Plugin/Source/Processors/Hysteresis/DCBlocker.h b/Plugin/Source/Processors/Hysteresis/DCBlocker.h @@ -33,7 +33,8 @@ public: float c = 1.0f / dsp::FastMathApproximations::tan (wc / 2.0f); float phi = c * c; - float b[3], a[3]; + float b[3]; + float a[3]; for (int i = 0; i < 2; ++i) { float K = c / Qs[i]; diff --git a/Plugin/Source/Processors/Hysteresis/HysteresisOps.h b/Plugin/Source/Processors/Hysteresis/HysteresisOps.h @@ -44,15 +44,15 @@ constexpr double NEG_TWO_OVER_15 = -2.0 / 15.0; constexpr inline int sign (double x) { - return (x > 0.0) - (x < 0.0); + return int (x > 0.0) - int (x < 0.0); } /** Langevin function */ -template<typename Float, typename Bool> +template <typename Float, typename Bool> static inline Float langevin (Float x, Float coth, Bool nearZero) noexcept { #if HYSTERESIS_USE_SIMD - auto notNearZero = ~ nearZero; + auto notNearZero = ~nearZero; return ((coth - ((Float) 1.0 / x)) & notNearZero) + ((x / 3.0) & nearZero); #else return ! nearZero ? (coth) - (1.0 / x) : x / 3.0; @@ -60,11 +60,11 @@ static inline Float langevin (Float x, Float coth, Bool nearZero) noexcept } /** Derivative of Langevin function */ -template<typename Float, typename Bool> +template <typename Float, typename Bool> static inline Float langevinD (Float x, Float coth, Bool nearZero) noexcept { #if HYSTERESIS_USE_SIMD - auto notNearZero = ~ nearZero; + auto notNearZero = ~nearZero; return ((((Float) 1.0 / (x * x)) - (coth * coth) + 1.0) & notNearZero) + ((Float) ONE_THIRD & nearZero); #else return ! nearZero ? (1.0 / (x * x)) - (coth * coth) + 1.0 : ONE_THIRD; @@ -72,22 +72,22 @@ static inline Float langevinD (Float x, Float coth, Bool nearZero) noexcept } /** 2nd derivative of Langevin function */ -template<typename Float, typename Bool> +template <typename Float, typename Bool> static inline Float langevinD2 (Float x, Float coth, Bool nearZero) noexcept { #if HYSTERESIS_USE_SIMD - auto notNearZero = ~ nearZero; + auto notNearZero = ~nearZero; return (((Float) 2.0 * coth * (coth * coth - 1.0) - ((Float) 2.0 / (x * x * x))) & notNearZero) - + ((x * NEG_TWO_OVER_15) & nearZero); + + ((x * NEG_TWO_OVER_15) & nearZero); #else return ! nearZero - ? 2.0 * coth * (coth * coth - 1.0) - (2.0 / (x * x * x)) - : NEG_TWO_OVER_15 * x; + ? 2.0 * coth * (coth * coth - 1.0) - (2.0 / (x * x * x)) + : NEG_TWO_OVER_15 * x; #endif } /** Derivative by alpha transform */ -template<typename Float> +template <typename Float> static inline Float deriv (Float x_n, Float x_n1, Float x_d_n1, Float T) noexcept { const Float dAlpha = 0.75; @@ -95,7 +95,7 @@ static inline Float deriv (Float x_n, Float x_n1, Float x_d_n1, Float T) noexcep } /** hysteresis function dM/dt */ -template<typename Float> +template <typename Float> static inline Float hysteresisFunc (Float M, Float H, Float H_d, HysteresisState& hp) noexcept { hp.Q = (H + M * hp.alpha) * (1.0 / hp.a); @@ -131,7 +131,7 @@ static inline Float hysteresisFunc (Float M, Float H, Float H_d, HysteresisState } // derivative of hysteresis func w.r.t M (depends on cached values from computing hysteresisFunc) -template<typename Float> +template <typename Float> static inline Float hysteresisFuncPrime (Float H_d, Float dMdt, HysteresisState& hp) noexcept { const Float L_prime2 = langevinD2 (hp.Q, hp.coth, hp.nearZero); diff --git a/Plugin/Source/Processors/Hysteresis/HysteresisProcessing.cpp b/Plugin/Source/Processors/Hysteresis/HysteresisProcessing.cpp @@ -1,5 +1,5 @@ #include "HysteresisProcessing.h" -#include <math.h> +#include <cmath> HysteresisProcessing::HysteresisProcessing() { diff --git a/Plugin/Source/Processors/Hysteresis/HysteresisProcessing.h b/Plugin/Source/Processors/Hysteresis/HysteresisProcessing.h @@ -30,7 +30,7 @@ public: void cook (float drive, float width, float sat, bool v1); /* Process a single sample */ - template<SolverType solver, typename Float> + template <SolverType solver, typename Float> inline Float process (Float H) noexcept { auto H_d = HysteresisOps::deriv (H, H_n1, H_d_n1, (Float) T); @@ -38,36 +38,36 @@ public: Float M; switch (solver) { - case RK2: - M = RK2Solver (H, H_d); - break; - case RK4: - M = RK4Solver (H, H_d); - break; - case NR4: - M = NRSolver<4> (H, H_d); - break; - case NR8: - M = NRSolver<8> (H, H_d); - break; - case STN: - M = STNSolver (H, H_d); - break; - - default: - M = 0.0; + case RK2: + M = RK2Solver (H, H_d); + break; + case RK4: + M = RK4Solver (H, H_d); + break; + case NR4: + M = NRSolver<4> (H, H_d); + break; + case NR8: + M = NRSolver<8> (H, H_d); + break; + case STN: + M = STNSolver (H, H_d); + break; + + default: + M = 0.0; }; - // check for instability - #if HYSTERESIS_USE_SIMD - auto notIllCondition = ~ (chowdsp::SIMDUtils::isnanSIMD (M) | Float::greaterThan (M, (Float) upperLim)); + // check for instability +#if HYSTERESIS_USE_SIMD + auto notIllCondition = ~(chowdsp::SIMDUtils::isnanSIMD (M) | Float::greaterThan (M, (Float) upperLim)); M = M & notIllCondition; H_d = H_d & notIllCondition; - #else +#else bool illCondition = std::isnan (M) || M > upperLim; M = illCondition ? 0.0 : M; H_d = illCondition ? 0.0 : H_d; - #endif +#endif M_n1 = M; H_n1 = H; @@ -78,7 +78,7 @@ public: private: // runge-kutta solvers - template<typename Float> + template <typename Float> inline Float RK2Solver (Float H, Float H_d) noexcept { const Float k1 = HysteresisOps::hysteresisFunc (M_n1, H_n1, H_d_n1, hpState) * T; @@ -87,7 +87,7 @@ private: return M_n1 + k2; } - template<typename Float> + template <typename Float> inline Float RK4Solver (Float H, Float H_d) noexcept { const Float H_1_2 = (H + H_n1) * 0.5; @@ -104,7 +104,7 @@ private: } // newton-raphson solvers - template<int nIterations, typename Float> + template <int nIterations, typename Float> inline Float NRSolver (Float H, Float H_d) noexcept { using namespace chowdsp::SIMDUtils; @@ -112,7 +112,9 @@ private: Float M = M_n1; const Float last_dMdt = HysteresisOps::hysteresisFunc (M_n1, H_n1, H_d_n1, hpState); - Float dMdt, dMdtPrime, deltaNR; + Float dMdt; + Float dMdtPrime; + Float deltaNR; for (int n = 0; n < nIterations; ++n) { dMdt = HysteresisOps::hysteresisFunc (M, H, H_d, hpState); @@ -125,32 +127,36 @@ private: } // state transition network solver - template<typename Float> + template <typename Float> inline Float STNSolver (Float H, Float H_d) noexcept { #if HYSTERESIS_USE_SIMD - double H_arr[2], H_d_arr[2], H_n1_arr[2], H_d_n1_arr[2], M_n1_arr[2]; - double M_out alignas (16)[2]; - - H.copyToRawArray (H_arr); - H_d.copyToRawArray (H_d_arr); - H_n1.copyToRawArray (H_n1_arr); - H_d_n1.copyToRawArray (H_d_n1_arr); - M_n1.copyToRawArray (M_n1_arr); + double H_arr[2]; + double H_d_arr[2]; + double H_n1_arr[2]; + double H_d_n1_arr[2]; + double M_n1_arr[2]; + double M_out alignas (16)[2]; + + H.copyToRawArray (H_arr); + H_d.copyToRawArray (H_d_arr); + H_n1.copyToRawArray (H_n1_arr); + H_d_n1.copyToRawArray (H_d_n1_arr); + M_n1.copyToRawArray (M_n1_arr); + + for (int ch = 0; ch < 2; ++ch) + { + double input alignas (16)[5] = { H_arr[ch], H_d_arr[ch], H_n1_arr[ch], H_d_n1_arr[ch], M_n1_arr[ch] }; - for (int ch = 0; ch < 2; ++ch) - { - double input alignas (16)[5] = { H_arr[ch], H_d_arr[ch], H_n1_arr[ch], H_d_n1_arr[ch], M_n1_arr[ch] }; + // scale derivatives + input[1] *= HysteresisSTN::diffMakeup; + input[3] *= HysteresisSTN::diffMakeup; + FloatVectorOperations::multiply (input, 0.7071 / hpState.a, 4); // scale by drive param - // scale derivatives - input[1] *= HysteresisSTN::diffMakeup; - input[3] *= HysteresisSTN::diffMakeup; - FloatVectorOperations::multiply (input, 0.7071 / hpState.a, 4); // scale by drive param - - M_out[ch] = hysteresisSTN.process (input) + M_n1_arr[ch]; - } + M_out[ch] = hysteresisSTN.process (input) + M_n1_arr[ch]; + } - return Float::fromRawArray (M_out); + return Float::fromRawArray (M_out); #else double input alignas (16)[5] = { H, H_d, H_n1, H_d_n1, M_n1 }; diff --git a/Plugin/Source/Processors/Hysteresis/HysteresisProcessor.cpp b/Plugin/Source/Processors/Hysteresis/HysteresisProcessor.cpp @@ -9,33 +9,33 @@ enum constexpr double v1Norm = 1.414 / 10000.0; -template<typename T> +template <typename T> static void interleaveSamples (const T** source, T* dest, int numSamples, int numChannels) { for (int chan = 0; chan < numChannels; ++chan) { auto i = chan; - auto src = source [chan]; + auto src = source[chan]; for (int j = 0; j < numSamples; ++j) { - dest [i] = src [j]; + dest[i] = src[j]; i += numChannels; } } } -template<typename T> +template <typename T> static void deinterleaveSamples (const T* source, T** dest, int numSamples, int numChannels) { for (int chan = 0; chan < numChannels; ++chan) { auto i = chan; - auto dst = dest [chan]; + auto dst = dest[chan]; for (int j = 0; j < numSamples; ++j) { - dst [j] = source [i]; + dst[j] = source[i]; i += numChannels; } } @@ -56,7 +56,7 @@ HysteresisProcessor::HysteresisProcessor (AudioProcessorValueTreeState& vts, con width[ch].reset (numSteps); sat[ch].reset (numSteps); } - + makeup.reset (numSteps); } @@ -161,7 +161,7 @@ void HysteresisProcessor::prepareToPlay (double sampleRate, int samplesPerBlock) biasAngle[ch] = 0.0; } - + makeup.skip (numSteps); osManager.prepareToPlay (sampleRate, samplesPerBlock); @@ -174,7 +174,7 @@ void HysteresisProcessor::prepareToPlay (double sampleRate, int samplesPerBlock) #if HYSTERESIS_USE_SIMD const auto maxOSBlockSize = (uint32) samplesPerBlock * 16; interleaved = dsp::AudioBlock<Vec2> (interleavedBlockData, 1, maxOSBlockSize); - zero = dsp::AudioBlock<double> (zeroData, Vec2::size(), maxOSBlockSize); + zero = dsp::AudioBlock<double> (zeroData, Vec2::size(), maxOSBlockSize); zero.clear(); #endif } @@ -231,10 +231,9 @@ void HysteresisProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& auto* inout = channelPointers.getData(); for (size_t ch = 0; ch < Vec2::size(); ++ch) inout[ch] = (ch < osBlock.getNumChannels() ? const_cast<double*> (osBlock.getChannelPointer (ch)) : zero.getChannelPointer (ch)); - + // interleave channels - interleaveSamples (inout, reinterpret_cast<double*> (interleaved.getChannelPointer (0)), - static_cast<int> (n), static_cast<int> (Vec2::size())); + interleaveSamples (inout, reinterpret_cast<double*> (interleaved.getChannelPointer (0)), static_cast<int> (n), static_cast<int> (Vec2::size())); auto processBlock = interleaved.getSubBlock (0, n); #else @@ -252,46 +251,47 @@ void HysteresisProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& { switch (solver) { - case RK2: - if (needsSmoothing) - processSmooth<RK2> (processBlock); - else - process<RK2> (processBlock); - break; - case RK4: - if (needsSmoothing) - processSmooth<RK4> (processBlock); - else - process<RK4> (processBlock); - break; - case NR4: - if (needsSmoothing) - processSmooth<NR4> (processBlock); - else - process<NR4> (processBlock); - break; - case NR8: - if (needsSmoothing) - processSmooth<NR8> (processBlock); - else - process<NR8> (processBlock); - break; - case STN: - if (needsSmoothing) - processSmooth<STN> (processBlock); - else - process<STN> (processBlock); - break; - default: - jassertfalse; // unknown solver! - }; + case RK2: + if (needsSmoothing) + processSmooth<RK2> (processBlock); + else + process<RK2> (processBlock); + break; + case RK4: + if (needsSmoothing) + processSmooth<RK4> (processBlock); + else + process<RK4> (processBlock); + break; + case NR4: + if (needsSmoothing) + processSmooth<NR4> (processBlock); + else + process<NR4> (processBlock); + break; + case NR8: + if (needsSmoothing) + processSmooth<NR8> (processBlock); + else + process<NR8> (processBlock); + break; + case STN: + if (needsSmoothing) + processSmooth<STN> (processBlock); + else + process<STN> (processBlock); + break; + default: + jassertfalse; // unknown solver! + }; } #if HYSTERESIS_USE_SIMD // de-interleave channels deinterleaveSamples (reinterpret_cast<double*> (interleaved.getChannelPointer (0)), const_cast<double**> (inout), - static_cast<int> (n), static_cast<int> (Vec2::size())); + static_cast<int> (n), + static_cast<int> (Vec2::size())); #endif osManager.getOversampler()->processSamplesDown (block); @@ -343,7 +343,7 @@ void HysteresisProcessor::process (dsp::AudioBlock<T>& block) for (size_t samp = 0; samp < block.getNumSamples(); samp++) x[samp] = hProcs[channel].process<solverType> (x[samp]); } - + applyMakeup (block, makeup); } @@ -363,7 +363,7 @@ void HysteresisProcessor::processSmooth (dsp::AudioBlock<T>& block) applyMakeup (block, makeup); } -template<typename T> +template <typename T> void HysteresisProcessor::processV1 (dsp::AudioBlock<T>& block) { const auto angleDelta = MathConstants<double>::twoPi * biasFreq / (fs * osManager.getOSFactor()); @@ -382,7 +382,7 @@ void HysteresisProcessor::processV1 (dsp::AudioBlock<T>& block) } } -template<typename T> +template <typename T> void HysteresisProcessor::processSmoothV1 (dsp::AudioBlock<T>& block) { const auto angleDelta = MathConstants<double>::twoPi * biasFreq / (fs * osManager.getOSFactor()); diff --git a/Plugin/Source/Processors/Hysteresis/HysteresisSTN.cpp b/Plugin/Source/Processors/Hysteresis/HysteresisSTN.cpp @@ -8,9 +8,9 @@ constexpr double trainingSampleRate = 96e3; constexpr float satIdxMult = (float) HysteresisSTN::numSatModels - 1.0f; constexpr float widthIdxMult = (float) HysteresisSTN::numWidthModels - 1.0f; -static std::array<String, HysteresisSTN::numWidthModels> widthTags { "0", "10", "20", "30", "40", "50", "60", "70", "80", "90", "100" }; +const std::array<String, HysteresisSTN::numWidthModels> widthTags { "0", "10", "20", "30", "40", "50", "60", "70", "80", "90", "100" }; -static std::array<String, HysteresisSTN::numSatModels> satTags { "0", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70", "75", "80", "85", "90", "95", "100" }; +const std::array<String, HysteresisSTN::numSatModels> satTags { "0", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70", "75", "80", "85", "90", "95", "100" }; } // namespace constexpr size_t getSatIdx (float satParam) diff --git a/Plugin/Source/Processors/Loss_Effects/AzimuthProc.cpp b/Plugin/Source/Processors/Loss_Effects/AzimuthProc.cpp @@ -2,12 +2,12 @@ namespace { -static constexpr float inches2meters (float inches) +constexpr float inches2meters (float inches) { return inches / 39.370078740157f; } -static constexpr float deg2rad (float deg) +constexpr float deg2rad (float deg) { return deg * MathConstants<float>::pi / 180.0f; } @@ -30,7 +30,7 @@ void AzimuthProc::prepare (double sampleRate, int samplesPerBlock) void AzimuthProc::setAzimuthAngle (float angleDeg, float tapeSpeedIps) { - const size_t delayIdx = size_t (angleDeg < 0.0f); + const auto delayIdx = size_t (angleDeg < 0.0f); const auto tapeSpeed = inches2meters (tapeSpeedIps); const auto azimuthAngle = deg2rad (std::abs (angleDeg));