chris@164: /* chris@164: * chris@164: * Excitation Junction for two waveguides chris@164: * chris@164: * Christian Heinrichs 04/2015 chris@164: * chris@164: */ chris@164: chris@164: #ifndef JUNCTION_H_ chris@164: #define JUNCTION_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 M_PI chris@164: #define M_PI 3.14159265358979323846264338 chris@164: #endif chris@164: chris@164: class Junction chris@164: { chris@164: chris@164: public: chris@164: chris@164: Junction(); chris@164: void setup(); chris@164: void update(float excitation, float left, float right); chris@164: float getOutput(int direction); chris@164: float getExcitationDisplacement(); chris@164: void setFrequency(float frequency); chris@164: void setPeriod(float periodInMs); chris@164: void setPluckPosition(float pluckPos); chris@164: chris@164: private: chris@164: chris@164: double _dt; chris@164: float _periodInMilliseconds; chris@164: int _periodInSamples; chris@164: chris@164: int _delay_l; chris@164: int _delay_r; chris@164: chris@164: float _buffer_l[WG_BUFFER_SIZE]; chris@164: float _buffer_r[WG_BUFFER_SIZE]; chris@164: int _readPtr; chris@164: chris@164: float _excitation; chris@164: float _lastPlectrumDisplacement; chris@164: chris@164: }; chris@164: chris@164: #endif