robert@464: /* robert@464: * FeedbackOscillator.h robert@464: * robert@464: * Created on: June 8, 2014 robert@464: * Author: Andrew McPherson robert@464: */ robert@464: robert@464: #ifndef FEEDBACKOSCILLATOR_H robert@464: #define FEEDBACKOSCILLATOR_H robert@464: robert@464: class FeedbackOscillator robert@464: { robert@464: public: robert@464: FeedbackOscillator(); robert@464: ~FeedbackOscillator(); robert@464: robert@464: // Initialise the settings for the feedback oscillator robert@464: void initialise(int maxTableSize, float hpfCutoffFrequency, float matrixSampleRate); robert@464: robert@464: // Process one sample and store the output value robert@464: // Returns the length of table to interpolate; or 0 if nothing to process further robert@464: int process(float input, float *output); robert@464: robert@464: float *wavetable() { return wavetableRead; } robert@464: robert@464: private: robert@464: float coeffs[3]; // Coefficients of first-order high-pass filter robert@464: float lastInput; // last input sample for HPF robert@464: float lastOutput; // last output sample of HPF robert@464: bool triggered; // whether we are currently saving samples robert@464: bool canTrigger; // whether we are able to begin saving samples robert@464: int wavetableMaxLength; // how long the stored wavetable can be robert@464: int sampleCount; // how many samples have elapsed robert@464: int lastTriggerCount; // sample count when we last triggered robert@464: robert@464: float *wavetable1, *wavetable2; // Two wavetables where we record samples robert@464: float *wavetableRead, *wavetableWrite; // Pointers to the above wavetables robert@464: int wavetableWritePointer; // Where we are currently writing robert@464: }; robert@464: robert@464: #endif