annotate examples/10-Instruments/airharp/Waveguide.h @ 531:ddb86944e138 prerelease

cleaned up all pd examples (and removed some). added polysynth and vangelisiser to instruments examples
author chnrx <chris.heinrichs@gmail.com>
date Thu, 23 Jun 2016 20:40:05 +0100
parents 8fcfbfb32aa0
children
rev   line source
robert@464 1 /*
robert@464 2 *
robert@464 3 * Simple 1-Dimensional Waveguide
robert@464 4 *
robert@464 5 * Christian Heinrichs 04/2015
robert@464 6 *
robert@464 7 */
robert@464 8
robert@464 9 #ifndef WAVEGUIDE_H_
robert@464 10 #define WAVEGUIDE_H_
robert@464 11
robert@464 12 #include <cmath>
robert@464 13
robert@464 14 #ifndef WG_BUFFER_SIZE
robert@464 15 #define WG_BUFFER_SIZE 4096
robert@464 16 #endif
robert@464 17
robert@464 18 #ifndef FILTER_BUFFER_SIZE
robert@464 19 #define FILTER_BUFFER_SIZE 4
robert@464 20 #endif
robert@464 21
robert@464 22 #ifndef M_PI
robert@464 23 #define M_PI 3.14159265358979323846264338
robert@464 24 #endif
robert@464 25
robert@464 26 class Waveguide
robert@464 27 {
robert@464 28
robert@464 29 public:
robert@464 30
robert@464 31 Waveguide();
robert@464 32 void setup();
robert@464 33 float update(float in);
robert@464 34 void updateFilterCoeffs(float frequency);
robert@464 35 void setFrequency(float frequency);
robert@464 36
robert@464 37 private:
robert@464 38
robert@464 39 double _dt;
robert@464 40 float _periodInMilliseconds;
robert@464 41 int _periodInSamples;
robert@464 42
robert@464 43 float _buffer[WG_BUFFER_SIZE];
robert@464 44 int _readPtr;
robert@464 45
robert@464 46 float _filterBuffer_x[FILTER_BUFFER_SIZE];
robert@464 47 float _filterBuffer_y[FILTER_BUFFER_SIZE];
robert@464 48 float _hipBuffer_x[FILTER_BUFFER_SIZE];
robert@464 49 float _hipBuffer_y[FILTER_BUFFER_SIZE];
robert@464 50 int _filterReadPtr;
robert@464 51
robert@464 52 float b0_lp,b1_lp,b2_lp,a1_lp, a2_lp;
robert@464 53 float _lastY,_lastX;
robert@464 54
robert@464 55 };
robert@464 56
robert@464 57 #endif