annotate examples/airharp/Waveguide.h @ 339:02e6f96466f8 prerelease

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