comparison examples/10-Instruments/airharp/Waveguide.h @ 464:8fcfbfb32aa0 prerelease

Examples reorder with subdirectories. Added header to each project. Moved Doxygen to bottom of render.cpp.
author Robert Jack <robert.h.jack@gmail.com>
date Mon, 20 Jun 2016 16:20:38 +0100
parents
children
comparison
equal deleted inserted replaced
463:c47709e8b5c9 464:8fcfbfb32aa0
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