AnalogTapeModel

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

HysteresisSTN.h (1204B)


      1 #ifndef HYSTERESISSTN_H_INCLUDED
      2 #define HYSTERESISSTN_H_INCLUDED
      3 
      4 // #include "RTNeural/src/Model.h"
      5 #include "STNModel.h"
      6 #include <JuceHeader.h>
      7 #include <RTNeural/RTNeural.h>
      8 
      9 /**
     10  * Class that implements a "State Transition Network" for
     11  * solving a state space formulation of the hysteresis algorithm.
     12  *
     13  * For more information, see: Parker et. al., 2019 (http://dafx2019.bcu.ac.uk/papers/DAFx2019_paper_42.pdf)
     14  */
     15 class HysteresisSTN
     16 {
     17 public:
     18     HysteresisSTN();
     19     HysteresisSTN (HysteresisSTN&&) noexcept = default;
     20 
     21     static constexpr size_t inputSize = 5;
     22     static constexpr double diffMakeup = 1.0 / 6.0e4;
     23 
     24     void prepare (double sampleRate);
     25     void setParams (float saturation, float width);
     26 
     27     inline double process (const double* input) noexcept
     28     {
     29         return stnModels[widthIdx][satIdx].forward (input) * sampleRateCorr;
     30     }
     31 
     32     enum
     33     {
     34         numWidthModels = 11,
     35         numSatModels = 21
     36     };
     37 
     38 private:
     39     STNSpace::STNModel stnModels[numWidthModels][numSatModels];
     40     double sampleRateCorr = 1.0;
     41     size_t widthIdx = 0;
     42     size_t satIdx = 0;
     43 
     44     JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (HysteresisSTN)
     45 };
     46 
     47 #endif // HYSTERESISSTN_H_INCLUDED