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