diff projects/basic_analog_output/render.cpp @ 13:6adb088196a7

Fixed ADC bug; added a simple passthrough test
author andrewm
date Fri, 23 Jan 2015 15:17:09 +0000
parents a6beeba3a648
children a6d223473ea2
line wrap: on
line diff
--- a/projects/basic_analog_output/render.cpp	Thu Jan 22 19:00:22 2015 +0000
+++ b/projects/basic_analog_output/render.cpp	Fri Jan 23 15:17:09 2015 +0000
@@ -19,8 +19,6 @@
 float gPhase;
 float gInverseSampleRate;
 
-int gMatrixChannels;
-
 // initialise_render() is called once before the audio rendering starts.
 // Use it to perform any initialisation and allocation which is dependent
 // on the period size or sample rate.
@@ -44,7 +42,6 @@
 		return false;
 	}
 
-	gMatrixChannels = numMatrixChannels;
 	gInverseSampleRate = 1.0 / matrixSampleRate;
 	gPhase = 0.0;
 
@@ -62,13 +59,12 @@
 	for(int n = 0; n < numMatrixFrames; n++) {
 		// Set LED to different phase for each matrix channel
 		float relativePhase = 0.0;
-		for(int channel = 0; channel < gMatrixChannels; channel++) {
+		for(int channel = 0; channel < gNumMatrixChannels; channel++) {
 			float out = kMinimumAmplitude + kAmplitudeRange * 0.5f * (1.0f + sinf(gPhase + relativePhase));
 			if(out > MATRIX_MAX)
 				out = MATRIX_MAX;
 
-			matrixOut[n * gMatrixChannels + channel] = (uint16_t)out;
-			//analogWrite(channel, n, out);
+			analogWrite(channel, n, out);
 
 			// Advance by pi/4 (1/8 of a full rotation) for each channel
 			relativePhase += M_PI * 0.25;