Mercurial > hg > beaglert
annotate projects/d-box/FeedbackOscillator.h @ 66:74a44c3d91f0 newapi
Some initial, partial documentation in Utilities.h
author | andrewm |
---|---|
date | Wed, 15 Jul 2015 23:55:48 +0100 |
parents | be427da6fb9c |
children |
rev | line source |
---|---|
andrewm@0 | 1 /* |
andrewm@0 | 2 * FeedbackOscillator.h |
andrewm@0 | 3 * |
andrewm@0 | 4 * Created on: June 8, 2014 |
andrewm@0 | 5 * Author: Andrew McPherson |
andrewm@0 | 6 */ |
andrewm@0 | 7 |
andrewm@0 | 8 #ifndef FEEDBACKOSCILLATOR_H |
andrewm@0 | 9 #define FEEDBACKOSCILLATOR_H |
andrewm@0 | 10 |
andrewm@0 | 11 class FeedbackOscillator |
andrewm@0 | 12 { |
andrewm@0 | 13 public: |
andrewm@0 | 14 FeedbackOscillator(); |
andrewm@0 | 15 ~FeedbackOscillator(); |
andrewm@0 | 16 |
andrewm@0 | 17 // Initialise the settings for the feedback oscillator |
andrewm@0 | 18 void initialise(int maxTableSize, float hpfCutoffFrequency, float matrixSampleRate); |
andrewm@0 | 19 |
andrewm@0 | 20 // Process one sample and store the output value |
andrewm@0 | 21 // Returns the length of table to interpolate; or 0 if nothing to process further |
andrewm@50 | 22 int process(float input, float *output); |
andrewm@0 | 23 |
andrewm@0 | 24 float *wavetable() { return wavetableRead; } |
andrewm@0 | 25 |
andrewm@0 | 26 private: |
andrewm@0 | 27 float coeffs[3]; // Coefficients of first-order high-pass filter |
andrewm@0 | 28 float lastInput; // last input sample for HPF |
andrewm@0 | 29 float lastOutput; // last output sample of HPF |
andrewm@0 | 30 bool triggered; // whether we are currently saving samples |
andrewm@0 | 31 bool canTrigger; // whether we are able to begin saving samples |
andrewm@0 | 32 int wavetableMaxLength; // how long the stored wavetable can be |
andrewm@0 | 33 int sampleCount; // how many samples have elapsed |
andrewm@0 | 34 int lastTriggerCount; // sample count when we last triggered |
andrewm@0 | 35 |
andrewm@0 | 36 float *wavetable1, *wavetable2; // Two wavetables where we record samples |
andrewm@0 | 37 float *wavetableRead, *wavetableWrite; // Pointers to the above wavetables |
andrewm@0 | 38 int wavetableWritePointer; // Where we are currently writing |
andrewm@0 | 39 }; |
andrewm@0 | 40 |
andrewm@0 | 41 #endif |