diff projects/audio_in_FFT/render.cpp @ 52:a6d223473ea2 newapi

Updated examples for new API. tank_wars not yet updated; audio_in_FFT and oscillator_bank not working properly yet.
author andrewm
date Sun, 31 May 2015 02:13:39 -0500
parents 06f93bef7dd2
children 3c3a1357657d
line wrap: on
line diff
--- a/projects/audio_in_FFT/render.cpp	Sat May 30 13:25:51 2015 -0500
+++ b/projects/audio_in_FFT/render.cpp	Sun May 31 02:13:39 2015 -0500
@@ -6,7 +6,7 @@
  */
 
 
-#include "../../include/render.h"
+#include "../../include/BeagleRT.h"
 #include <rtdk.h>
 #include <NE10.h>					// neon library
 #include <cmath>
@@ -32,11 +32,7 @@
 //
 // Return true on success; returning false halts the program.
 
-bool initialise_render(int numMatrixChannels, int numAudioChannels,
-					   int numMatrixFramesPerPeriod,
-					   int numAudioFramesPerPeriod,
-					   float matrixSampleRate, float audioSampleRate,
-					   void *userData)
+bool initialise_render(BeagleRTContext *context, void *userData)
 {
 	// Retrieve a parameter passed in from the initAudio() call
 	gFFTSize = *(int *)userData;
@@ -57,11 +53,11 @@
 // ADCs and DACs (if available). If only audio is available, numMatrixFrames
 // will be 0.
 
-void render(int numMatrixFrames, int numAudioFrames, float *audioIn, float *audioOut,
-			uint16_t *matrixIn, uint16_t *matrixOut)
+void render(BeagleRTContext *context, void *userData)
 {
-	for(int n = 0; n < numAudioFrames; n++) {
-		timeDomainIn[gReadPointer].r = (ne10_float32_t) ((audioIn[n*gNumAudioChannels] + audioIn[n*gNumAudioChannels+1]) * 0.5);
+	for(unsigned int n = 0; n < context->audioFrames; n++) {
+		timeDomainIn[gReadPointer].r = (ne10_float32_t) ((context->audioIn[n*context->audioChannels] +
+															context->audioIn[n*context->audioChannels+1]) * 0.5);
 		timeDomainIn[gReadPointer].i = 0;
 
 		if(++gReadPointer >= gFFTSize)
@@ -78,8 +74,8 @@
 			gWritePointer = 0;
 		}
 
-		for(int channel = 0; channel < gNumAudioChannels; channel++)
-			audioOut[n * gNumAudioChannels + channel] = (float) timeDomainOut[gWritePointer].r * gFFTScaleFactor;
+		for(int channel = 0; channel < context->audioChannels; channel++)
+			context->audioOut[n * context->audioChannels + channel] = (float) timeDomainOut[gWritePointer].r * gFFTScaleFactor;
 		gWritePointer++;
 	}
 }
@@ -87,7 +83,7 @@
 // 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)
 {
 	NE10_FREE(timeDomainIn);
 	NE10_FREE(timeDomainOut);