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