comparison projects/d-box/FeedbackOscillator.h @ 0:8a575ba3ab52

Initial commit.
author andrewm
date Fri, 31 Oct 2014 19:10:17 +0100
parents
children be427da6fb9c
comparison
equal deleted inserted replaced
-1:000000000000 0:8a575ba3ab52
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 #include <stdint.h>
12
13 class FeedbackOscillator
14 {
15 public:
16 FeedbackOscillator();
17 ~FeedbackOscillator();
18
19 // Initialise the settings for the feedback oscillator
20 void initialise(int maxTableSize, float hpfCutoffFrequency, float matrixSampleRate);
21
22 // Process one sample and store the output value
23 // Returns the length of table to interpolate; or 0 if nothing to process further
24 int process(uint16_t input, uint16_t *output);
25
26 float *wavetable() { return wavetableRead; }
27
28 private:
29 float coeffs[3]; // Coefficients of first-order high-pass filter
30 float lastInput; // last input sample for HPF
31 float lastOutput; // last output sample of HPF
32 bool triggered; // whether we are currently saving samples
33 bool canTrigger; // whether we are able to begin saving samples
34 int wavetableMaxLength; // how long the stored wavetable can be
35 int sampleCount; // how many samples have elapsed
36 int lastTriggerCount; // sample count when we last triggered
37
38 float *wavetable1, *wavetable2; // Two wavetables where we record samples
39 float *wavetableRead, *wavetableWrite; // Pointers to the above wavetables
40 int wavetableWritePointer; // Where we are currently writing
41 };
42
43 #endif