SmartGuitarAmp

Guitar plugin made with JUCE that uses neural networks to emulate a tube amplifier
Log | Files | Refs | Submodules | README

Convolution.h (1436B)


      1 /*
      2   ==============================================================================
      3 
      4     Convolution.h
      5     Created: 3 Jan 2019 10:58:34am
      6     Author:  Damskägg Eero-Pekka
      7 
      8   ==============================================================================
      9 */
     10 
     11 #pragma once
     12 
     13 #include <Eigen/Core>
     14 #include <Eigen/StdVector>
     15 
     16 class Convolution
     17 {
     18 public:
     19     Convolution(size_t inputChannels, size_t outputChannels, int filterWidth, int dilation = 1);
     20     int getFilterOrder() const;
     21     void process(float* data, int numSamples);
     22     void setParams(size_t inputChannels, size_t outputChannels, int filterWidth, int dilation);
     23     size_t getNumInputChannels() { return inputChannels; }
     24     size_t getNumOutputChannels() { return outputChannels; }
     25     void setWeight(std::vector<float> W, std::string name);
     26 
     27 private:
     28     std::vector<Eigen::MatrixXf, Eigen::aligned_allocator<Eigen::MatrixXf >> kernel;
     29     Eigen::RowVectorXf bias;
     30     std::vector<Eigen::RowVectorXf, Eigen::aligned_allocator<Eigen::RowVectorXf> > memory;
     31     Eigen::RowVectorXf outVec;
     32     int pos;
     33     int dilation;
     34     size_t inputChannels;
     35     size_t outputChannels;
     36     int filterWidth;
     37     
     38     void resetFifo();
     39     void resetKernel();
     40     void processSingleSample(float* data, int i, int numSamples);
     41     
     42     int mod(int a, int b);
     43     int idx(int ch, int i, int numSamples);
     44     
     45     void setKernel(std::vector<float> W);
     46     void setBias(std::vector<float> W);
     47 };