chris@164: /* chris@164: * chris@164: * Simple 1-Dimensional Waveguide chris@164: * chris@164: * Christian Heinrichs 04/2015 chris@164: * chris@164: */ chris@164: chris@164: #ifndef WAVEGUIDE_H_ chris@164: #define WAVEGUIDE_H_ chris@164: chris@164: #include chris@164: chris@164: #ifndef WG_BUFFER_SIZE chris@164: #define WG_BUFFER_SIZE 4096 chris@164: #endif chris@164: chris@164: #ifndef FILTER_BUFFER_SIZE chris@164: #define FILTER_BUFFER_SIZE 4 chris@164: #endif chris@164: chris@164: #ifndef M_PI chris@164: #define M_PI 3.14159265358979323846264338 chris@164: #endif chris@164: chris@164: class Waveguide chris@164: { chris@164: chris@164: public: chris@164: chris@164: Waveguide(); chris@164: void setup(); chris@164: float update(float in); chris@164: void updateFilterCoeffs(float frequency); chris@164: void setFrequency(float frequency); chris@164: chris@164: private: chris@164: chris@164: double _dt; chris@164: float _periodInMilliseconds; chris@164: int _periodInSamples; chris@164: chris@164: float _buffer[WG_BUFFER_SIZE]; chris@164: int _readPtr; chris@164: chris@164: float _filterBuffer_x[FILTER_BUFFER_SIZE]; chris@164: float _filterBuffer_y[FILTER_BUFFER_SIZE]; chris@164: float _hipBuffer_x[FILTER_BUFFER_SIZE]; chris@164: float _hipBuffer_y[FILTER_BUFFER_SIZE]; chris@164: int _filterReadPtr; chris@164: chris@164: float b0_lp,b1_lp,b2_lp,a1_lp, a2_lp; chris@164: float _lastY,_lastX; chris@164: chris@164: }; chris@164: chris@164: #endif