Mercurial > hg > beaglert
comparison examples/10-Instruments/airharp/Waveguide.h @ 468:85cf9c0da052 prerelease
merge
| author | Giulio Moro <giuliomoro@yahoo.it> |
|---|---|
| date | Mon, 20 Jun 2016 17:08:02 +0100 |
| parents | 8fcfbfb32aa0 |
| children |
comparison
equal
deleted
inserted
replaced
| 467:03a2cd5f151b | 468:85cf9c0da052 |
|---|---|
| 1 /* | |
| 2 * | |
| 3 * Simple 1-Dimensional Waveguide | |
| 4 * | |
| 5 * Christian Heinrichs 04/2015 | |
| 6 * | |
| 7 */ | |
| 8 | |
| 9 #ifndef WAVEGUIDE_H_ | |
| 10 #define WAVEGUIDE_H_ | |
| 11 | |
| 12 #include <cmath> | |
| 13 | |
| 14 #ifndef WG_BUFFER_SIZE | |
| 15 #define WG_BUFFER_SIZE 4096 | |
| 16 #endif | |
| 17 | |
| 18 #ifndef FILTER_BUFFER_SIZE | |
| 19 #define FILTER_BUFFER_SIZE 4 | |
| 20 #endif | |
| 21 | |
| 22 #ifndef M_PI | |
| 23 #define M_PI 3.14159265358979323846264338 | |
| 24 #endif | |
| 25 | |
| 26 class Waveguide | |
| 27 { | |
| 28 | |
| 29 public: | |
| 30 | |
| 31 Waveguide(); | |
| 32 void setup(); | |
| 33 float update(float in); | |
| 34 void updateFilterCoeffs(float frequency); | |
| 35 void setFrequency(float frequency); | |
| 36 | |
| 37 private: | |
| 38 | |
| 39 double _dt; | |
| 40 float _periodInMilliseconds; | |
| 41 int _periodInSamples; | |
| 42 | |
| 43 float _buffer[WG_BUFFER_SIZE]; | |
| 44 int _readPtr; | |
| 45 | |
| 46 float _filterBuffer_x[FILTER_BUFFER_SIZE]; | |
| 47 float _filterBuffer_y[FILTER_BUFFER_SIZE]; | |
| 48 float _hipBuffer_x[FILTER_BUFFER_SIZE]; | |
| 49 float _hipBuffer_y[FILTER_BUFFER_SIZE]; | |
| 50 int _filterReadPtr; | |
| 51 | |
| 52 float b0_lp,b1_lp,b2_lp,a1_lp, a2_lp; | |
| 53 float _lastY,_lastX; | |
| 54 | |
| 55 }; | |
| 56 | |
| 57 #endif |
