diff projects/d-box/FeedbackOscillator.cpp @ 108:3068421c0737 ultra-staging

Merged default into ultra-staging
author Giulio Moro <giuliomoro@yahoo.it>
date Tue, 18 Aug 2015 00:35:15 +0100
parents 4f8db16f17b5
children
line wrap: on
line diff
--- a/projects/d-box/FeedbackOscillator.cpp	Mon Jun 08 01:07:48 2015 +0100
+++ b/projects/d-box/FeedbackOscillator.cpp	Tue Aug 18 00:35:15 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;
 }