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