Mercurial > hg > beaglert
diff projects/d-box/FeedbackOscillator.cpp @ 67:472e892c6e41
Merge newapi into default
author | Andrew McPherson <a.mcpherson@qmul.ac.uk> |
---|---|
date | Fri, 17 Jul 2015 15:28:18 +0100 |
parents | 4f8db16f17b5 |
children |
line wrap: on
line diff
--- a/projects/d-box/FeedbackOscillator.cpp Sun Feb 08 00:20:01 2015 +0000 +++ b/projects/d-box/FeedbackOscillator.cpp Fri Jul 17 15:28:18 2015 +0100 @@ -58,23 +58,16 @@ // Process one sample and store the output value // Returns true if the wavetable needs rendering -int FeedbackOscillator::process(uint16_t input, uint16_t *output) { - float inFloat = input / 65536.0; - float outFloat = coeffs[COEFF_B0] * inFloat + coeffs[COEFF_B1] * lastInput - coeffs[COEFF_A1] * lastOutput; +int FeedbackOscillator::process(float input, float *output) { + float outFloat = coeffs[COEFF_B0] * input + coeffs[COEFF_B1] * lastInput - coeffs[COEFF_A1] * lastOutput; int requestRenderLength = 0; - //outFloat *= 2.0; - - int intOut = outFloat * 65536.0 + 32768; - if(intOut > 65535) - intOut = 65535; - if(intOut < 0) - intOut = 0; - //intOut = (intOut & 0xFF) << 8; - //if(intOut > 65535) - // intOut = 65535; - - *output = (uint16_t)intOut; + if(outFloat < -0.5) + *output = 0; + else if(outFloat > 0.5) + *output = 1; + else + *output = outFloat + 0.5; if(canTrigger && outFloat > 0 && lastOutput <= 0) { triggered = true; @@ -106,7 +99,7 @@ sampleCount++; lastOutput = outFloat; - lastInput = inFloat; + lastInput = input; return requestRenderLength; }