comparison projects/d-box/FeedbackOscillator.cpp @ 50:be427da6fb9c newapi

Removed old testing code that stopped audio after 10 seconds; command line parameter updates; D-Box updates (not fully working yet)
author andrewm
date Sat, 30 May 2015 12:34:32 -0500
parents 8a575ba3ab52
children 4f8db16f17b5
comparison
equal deleted inserted replaced
49:bb40e7e06b8c 50:be427da6fb9c
56 sampleCount = lastTriggerCount = 0; 56 sampleCount = lastTriggerCount = 0;
57 } 57 }
58 58
59 // Process one sample and store the output value 59 // Process one sample and store the output value
60 // Returns true if the wavetable needs rendering 60 // Returns true if the wavetable needs rendering
61 int FeedbackOscillator::process(uint16_t input, uint16_t *output) { 61 int FeedbackOscillator::process(float input, float *output) {
62 float inFloat = input / 65536.0; 62 float outFloat = coeffs[COEFF_B0] * input + coeffs[COEFF_B1] * lastInput - coeffs[COEFF_A1] * lastOutput;
63 float outFloat = coeffs[COEFF_B0] * inFloat + coeffs[COEFF_B1] * lastInput - coeffs[COEFF_A1] * lastOutput;
64 int requestRenderLength = 0; 63 int requestRenderLength = 0;
65 64
66 //outFloat *= 2.0; 65 *output = outFloat;
67
68 int intOut = outFloat * 65536.0 + 32768;
69 if(intOut > 65535)
70 intOut = 65535;
71 if(intOut < 0)
72 intOut = 0;
73 //intOut = (intOut & 0xFF) << 8;
74 //if(intOut > 65535)
75 // intOut = 65535;
76
77 *output = (uint16_t)intOut;
78 66
79 if(canTrigger && outFloat > 0 && lastOutput <= 0) { 67 if(canTrigger && outFloat > 0 && lastOutput <= 0) {
80 triggered = true; 68 triggered = true;
81 requestRenderLength = wavetableWritePointer; // How many samples stored thus far? 69 requestRenderLength = wavetableWritePointer; // How many samples stored thus far?
82 if(requestRenderLength < 4) 70 if(requestRenderLength < 4)
104 canTrigger = true; 92 canTrigger = true;
105 93
106 sampleCount++; 94 sampleCount++;
107 95
108 lastOutput = outFloat; 96 lastOutput = outFloat;
109 lastInput = inFloat; 97 lastInput = input;
110 98
111 return requestRenderLength; 99 return requestRenderLength;
112 } 100 }