Mercurial > hg > beaglert
comparison projects/d-box/FeedbackOscillator.cpp @ 51:4f8db16f17b5 newapi
D-Box updates; should work as old version did
author | andrewm |
---|---|
date | Sat, 30 May 2015 13:25:51 -0500 |
parents | be427da6fb9c |
children |
comparison
equal
deleted
inserted
replaced
50:be427da6fb9c | 51:4f8db16f17b5 |
---|---|
60 // Returns true if the wavetable needs rendering | 60 // Returns true if the wavetable needs rendering |
61 int FeedbackOscillator::process(float input, float *output) { | 61 int FeedbackOscillator::process(float input, float *output) { |
62 float outFloat = coeffs[COEFF_B0] * input + coeffs[COEFF_B1] * lastInput - coeffs[COEFF_A1] * lastOutput; | 62 float outFloat = coeffs[COEFF_B0] * input + coeffs[COEFF_B1] * lastInput - coeffs[COEFF_A1] * lastOutput; |
63 int requestRenderLength = 0; | 63 int requestRenderLength = 0; |
64 | 64 |
65 *output = outFloat; | 65 if(outFloat < -0.5) |
66 *output = 0; | |
67 else if(outFloat > 0.5) | |
68 *output = 1; | |
69 else | |
70 *output = outFloat + 0.5; | |
66 | 71 |
67 if(canTrigger && outFloat > 0 && lastOutput <= 0) { | 72 if(canTrigger && outFloat > 0 && lastOutput <= 0) { |
68 triggered = true; | 73 triggered = true; |
69 requestRenderLength = wavetableWritePointer; // How many samples stored thus far? | 74 requestRenderLength = wavetableWritePointer; // How many samples stored thus far? |
70 if(requestRenderLength < 4) | 75 if(requestRenderLength < 4) |