diff --git a/src/ABC.cpp b/src/ABC.cpp index 4092883..d6d0191 100644 --- a/src/ABC.cpp +++ b/src/ABC.cpp @@ -1,5 +1,4 @@ #include "plugin.hpp" -#include "Common.hpp" using simd::float_4; diff --git a/src/ChoppingKinky.cpp b/src/ChoppingKinky.cpp index 023f6c2..ad025c5 100644 --- a/src/ChoppingKinky.cpp +++ b/src/ChoppingKinky.cpp @@ -1,5 +1,4 @@ #include "plugin.hpp" -#include "Common.hpp" #include "ChowDSP.hpp" diff --git a/src/ChowDSP.hpp b/src/ChowDSP.hpp index c4e2c44..c4f6db5 100644 --- a/src/ChowDSP.hpp +++ b/src/ChowDSP.hpp @@ -1,4 +1,6 @@ #pragma once +#include + namespace chowdsp { // code taken from https://github.com/jatinchowdhury18/ChowDSP-VCV/blob/master/src/shared/, commit 21701fb @@ -417,4 +419,4 @@ private: BaseOversampling* oss[NumOS] = { &os0, &os1, &os2, &os3, &os4 }; }; -} \ No newline at end of file +} // namespace chowdsp diff --git a/src/Common.hpp b/src/Common.hpp deleted file mode 100644 index b3480bd..0000000 --- a/src/Common.hpp +++ /dev/null @@ -1,112 +0,0 @@ -#pragma once - -#include -#include - -struct BefacoTinyKnobRed : app::SvgKnob { - BefacoTinyKnobRed() { - minAngle = -0.8 * M_PI; - maxAngle = 0.8 * M_PI; - setSvg(APP->window->loadSvg(asset::plugin(pluginInstance, "res/BefacoTinyKnobRed.svg"))); - } -}; - -struct BefacoTinyKnobWhite : app::SvgKnob { - BefacoTinyKnobWhite() { - minAngle = -0.8 * M_PI; - maxAngle = 0.8 * M_PI; - setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/BefacoTinyKnob.svg"))); - } -}; - -struct BefacoTinyKnobGrey : app::SvgKnob { - BefacoTinyKnobGrey() { - minAngle = -0.8 * M_PI; - maxAngle = 0.8 * M_PI; - setSvg(APP->window->loadSvg(asset::plugin(pluginInstance, "res/BefacoTinyKnobGrey.svg"))); - } -}; - -struct Davies1900hLargeGreyKnob : Davies1900hKnob { - Davies1900hLargeGreyKnob() { - setSvg(APP->window->loadSvg(asset::plugin(pluginInstance, "res/Davies1900hLargeGrey.svg"))); - } -}; - -struct BefacoOutputPort : app::SvgPort { - BefacoOutputPort() { - setSvg(APP->window->loadSvg(asset::plugin(pluginInstance, "res/BefacoOutputPort.svg"))); - } -}; - -struct BefacoInputPort : app::SvgPort { - BefacoInputPort() { - setSvg(APP->window->loadSvg(asset::plugin(pluginInstance, "res/BefacoInputPort.svg"))); - } -}; - -template -T sin2pi_pade_05_5_4(T x) { - x -= 0.5f; - return (T(-6.283185307) * x + T(33.19863968) * simd::pow(x, 3) - T(32.44191367) * simd::pow(x, 5)) - / (1 + T(1.296008659) * simd::pow(x, 2) + T(0.7028072946) * simd::pow(x, 4)); -} - -template -T tanh_pade(T x) { - T x2 = x * x; - T q = 12.f + x2; - return 12.f * x * q / (36.f * x2 + q * q); -} - - -struct ADEnvelope { - - enum Stage { - STAGE_OFF, - STAGE_ATTACK, - STAGE_DECAY - }; - - Stage stage = STAGE_OFF; - float env = 0.f; - float attackTime = 0.1, decayTime = 0.1; - float attackShape = 1.0, decayShape = 1.0; - - ADEnvelope() { }; - - void process(const float& sampleTime) { - - if (stage == STAGE_OFF) { - env = envLinear = 0.0f; - } - else if (stage == STAGE_ATTACK) { - envLinear += sampleTime / attackTime; - env = std::pow(envLinear, attackShape); - } - else if (stage == STAGE_DECAY) { - envLinear -= sampleTime / decayTime; - env = std::pow(envLinear, decayShape); - } - - if (envLinear >= 1.0f) { - stage = STAGE_DECAY; - env = envLinear = 1.0f; - } - else if (envLinear <= 0.0f) { - stage = STAGE_OFF; - env = envLinear = 0.0f; - } - } - - void trigger() { - stage = ADEnvelope::STAGE_ATTACK; - // non-linear envelopes won't retrigger at the correct starting point if - // attackShape != decayShape, so we advance the linear envelope - envLinear = std::pow(env, 1.0f / attackShape); - } - -private: - float envLinear = 0.f; - -}; \ No newline at end of file diff --git a/src/DualAtenuverter.cpp b/src/DualAtenuverter.cpp index 7c8816f..2b4bf63 100644 --- a/src/DualAtenuverter.cpp +++ b/src/DualAtenuverter.cpp @@ -1,5 +1,4 @@ #include "plugin.hpp" -#include "Common.hpp" struct DualAtenuverter : Module { enum ParamIds { diff --git a/src/EvenVCO.cpp b/src/EvenVCO.cpp index 181736c..1ea51a1 100644 --- a/src/EvenVCO.cpp +++ b/src/EvenVCO.cpp @@ -1,5 +1,4 @@ #include "plugin.hpp" -#include "Common.hpp" using simd::float_4; diff --git a/src/HexmixVCA.cpp b/src/HexmixVCA.cpp index 8ea5059..26c22b0 100644 --- a/src/HexmixVCA.cpp +++ b/src/HexmixVCA.cpp @@ -1,5 +1,4 @@ #include "plugin.hpp" -#include "Common.hpp" using simd::float_4; diff --git a/src/Kickall.cpp b/src/Kickall.cpp index c06a5b3..e64c2d4 100644 --- a/src/Kickall.cpp +++ b/src/Kickall.cpp @@ -1,5 +1,4 @@ #include "plugin.hpp" -#include "Common.hpp" #include "ChowDSP.hpp" diff --git a/src/Mixer.cpp b/src/Mixer.cpp index ae3d956..6ca38c5 100644 --- a/src/Mixer.cpp +++ b/src/Mixer.cpp @@ -1,5 +1,4 @@ #include "plugin.hpp" -#include "Common.hpp" using simd::float_4; diff --git a/src/Percall.cpp b/src/Percall.cpp index 083213e..e6a1d99 100644 --- a/src/Percall.cpp +++ b/src/Percall.cpp @@ -1,5 +1,4 @@ #include "plugin.hpp" -#include "Common.hpp" using simd::float_4; diff --git a/src/PulseGenerator_4.hpp b/src/PulseGenerator_4.hpp index 24afeac..d7cf182 100644 --- a/src/PulseGenerator_4.hpp +++ b/src/PulseGenerator_4.hpp @@ -1,11 +1,9 @@ #pragma once - -#include "rack.hpp" +#include /** When triggered, holds a high value for a specified time before going low again */ struct PulseGenerator_4 { - simd::float_4 remaining = simd::float_4::zero(); /** Immediately disables the pulse */ @@ -29,4 +27,3 @@ struct PulseGenerator_4 { remaining = ifelse(mask & (duration_4 > remaining), duration_4, remaining); } }; - diff --git a/src/Rampage.cpp b/src/Rampage.cpp index 5ca4dd5..bf3458f 100644 --- a/src/Rampage.cpp +++ b/src/Rampage.cpp @@ -1,5 +1,4 @@ #include "plugin.hpp" -#include "Common.hpp" #include "PulseGenerator_4.hpp" using simd::float_4; diff --git a/src/SlewLimiter.cpp b/src/SlewLimiter.cpp index 3cfe57b..3b7745c 100644 --- a/src/SlewLimiter.cpp +++ b/src/SlewLimiter.cpp @@ -1,5 +1,4 @@ #include "plugin.hpp" -#include "Common.hpp" using simd::float_4; diff --git a/src/SpringReverb.cpp b/src/SpringReverb.cpp index d982fdd..62f1ded 100644 --- a/src/SpringReverb.cpp +++ b/src/SpringReverb.cpp @@ -1,7 +1,5 @@ -#include #include "plugin.hpp" -#include "pffft.h" -#include "Common.hpp" +#include BINARY(src_SpringReverbIR_pcm); diff --git a/src/plugin.hpp b/src/plugin.hpp index 4bf7ea6..a6b8d71 100644 --- a/src/plugin.hpp +++ b/src/plugin.hpp @@ -1,4 +1,4 @@ -#include "rack.hpp" +#include using namespace rack; @@ -18,6 +18,7 @@ extern Model *modelHexmixVCA; extern Model *modelChoppingKinky; extern Model *modelKickall; + struct Knurlie : SvgScrew { Knurlie() { sw->svg = APP->window->loadSvg(asset::plugin(pluginInstance, "res/Knurlie.svg")); @@ -25,3 +26,109 @@ struct Knurlie : SvgScrew { box.size = sw->box.size; } }; + +struct BefacoTinyKnobRed : app::SvgKnob { + BefacoTinyKnobRed() { + minAngle = -0.8 * M_PI; + maxAngle = 0.8 * M_PI; + setSvg(APP->window->loadSvg(asset::plugin(pluginInstance, "res/BefacoTinyKnobRed.svg"))); + } +}; + +struct BefacoTinyKnobWhite : app::SvgKnob { + BefacoTinyKnobWhite() { + minAngle = -0.8 * M_PI; + maxAngle = 0.8 * M_PI; + setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/BefacoTinyKnob.svg"))); + } +}; + +struct BefacoTinyKnobGrey : app::SvgKnob { + BefacoTinyKnobGrey() { + minAngle = -0.8 * M_PI; + maxAngle = 0.8 * M_PI; + setSvg(APP->window->loadSvg(asset::plugin(pluginInstance, "res/BefacoTinyKnobGrey.svg"))); + } +}; + +struct Davies1900hLargeGreyKnob : Davies1900hKnob { + Davies1900hLargeGreyKnob() { + setSvg(APP->window->loadSvg(asset::plugin(pluginInstance, "res/Davies1900hLargeGrey.svg"))); + } +}; + +struct BefacoOutputPort : app::SvgPort { + BefacoOutputPort() { + setSvg(APP->window->loadSvg(asset::plugin(pluginInstance, "res/BefacoOutputPort.svg"))); + } +}; + +struct BefacoInputPort : app::SvgPort { + BefacoInputPort() { + setSvg(APP->window->loadSvg(asset::plugin(pluginInstance, "res/BefacoInputPort.svg"))); + } +}; + +template +T sin2pi_pade_05_5_4(T x) { + x -= 0.5f; + return (T(-6.283185307) * x + T(33.19863968) * simd::pow(x, 3) - T(32.44191367) * simd::pow(x, 5)) + / (1 + T(1.296008659) * simd::pow(x, 2) + T(0.7028072946) * simd::pow(x, 4)); +} + +template +T tanh_pade(T x) { + T x2 = x * x; + T q = 12.f + x2; + return 12.f * x * q / (36.f * x2 + q * q); +} + + +struct ADEnvelope { + enum Stage { + STAGE_OFF, + STAGE_ATTACK, + STAGE_DECAY + }; + + Stage stage = STAGE_OFF; + float env = 0.f; + float attackTime = 0.1, decayTime = 0.1; + float attackShape = 1.0, decayShape = 1.0; + + ADEnvelope() { }; + + void process(const float& sampleTime) { + + if (stage == STAGE_OFF) { + env = envLinear = 0.0f; + } + else if (stage == STAGE_ATTACK) { + envLinear += sampleTime / attackTime; + env = std::pow(envLinear, attackShape); + } + else if (stage == STAGE_DECAY) { + envLinear -= sampleTime / decayTime; + env = std::pow(envLinear, decayShape); + } + + if (envLinear >= 1.0f) { + stage = STAGE_DECAY; + env = envLinear = 1.0f; + } + else if (envLinear <= 0.0f) { + stage = STAGE_OFF; + env = envLinear = 0.0f; + } + } + + void trigger() { + stage = ADEnvelope::STAGE_ATTACK; + // non-linear envelopes won't retrigger at the correct starting point if + // attackShape != decayShape, so we advance the linear envelope + envLinear = std::pow(env, 1.0f / attackShape); + } + +private: + float envLinear = 0.f; +};