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