diff projects/basic/render.cpp @ 45:579c86316008 newapi

Major API overhaul. Moved to a single data structure for handling render functions. Functionally, generally similar except for scheduling within PRU loop function, which now uses interrupts from the PRU rather than polling. This requires an updated kernel.
author andrewm
date Thu, 28 May 2015 14:35:55 -0400
parents ad5cd8dd99b3
children 3c3a1357657d
line wrap: on
line diff
--- a/projects/basic/render.cpp	Wed May 13 12:23:37 2015 +0100
+++ b/projects/basic/render.cpp	Thu May 28 14:35:55 2015 -0400
@@ -6,7 +6,7 @@
  */
 
 
-#include "../../include/render.h"
+#include "../../include/BeagleRT.h"
 #include <cmath>
 
 float gFrequency;
@@ -22,16 +22,12 @@
 //
 // Return true on success; returning false halts the program.
 
-bool initialise_render(int numMatrixChannels,  int numDigitalChannels, int numAudioChannels,
-					   int numMatrixFramesPerPeriod,
-					   int numAudioFramesPerPeriod,
-					   float matrixSampleRate, float audioSampleRate,
-					   void *userData, RTAudioSettings* settings)
+bool initialise_render(BeagleRTContext *context, void *userData)
 {
 	// Retrieve a parameter passed in from the initAudio() call
 	gFrequency = *(float *)userData;
 
-	gInverseSampleRate = 1.0 / audioSampleRate;
+	gInverseSampleRate = 1.0 / context->audioSampleRate;
 	gPhase = 0.0;
 
 	return true;
@@ -42,24 +38,23 @@
 // ADCs and DACs (if available). If only audio is available, numMatrixFrames
 // will be 0.
 
-void render(int numAnalogFrames, int numAudioFrames, int numDigitalFrames, float *audioIn, float *audioOut,
-		float *analogIn, float *analogOut, uint32_t *digital)
+void render(BeagleRTContext *context, void *userData)
 {
-	for(int n = 0; n < numAudioFrames; n++) {
+	for(unsigned int n = 0; n < context->audioFrames; n++) {
 		float out = 0.8f * sinf(gPhase);
 		gPhase += 2.0 * M_PI * gFrequency * gInverseSampleRate;
 		if(gPhase > 2.0 * M_PI)
 			gPhase -= 2.0 * M_PI;
 
-		for(int channel = 0; channel < gNumAudioChannels; channel++)
-			audioOut[n * gNumAudioChannels + channel] = out;
+		for(unsigned int channel = 0; channel < context->audioChannels; channel++)
+			context->audioOut[n * context->audioChannels + channel] = out;
 	}
 }
 
 // cleanup_render() is called once at the end, after the audio has stopped.
 // Release any resources that were allocated in initialise_render().
 
-void cleanup_render()
+void cleanup_render(BeagleRTContext *context, void *userData)
 {
 
 }