diff projects/filter_IIR/render.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 3c3a1357657d
children 5433c83ce04e
line wrap: on
line diff
--- a/projects/filter_IIR/render.cpp	Mon Jun 08 01:07:48 2015 +0100
+++ b/projects/filter_IIR/render.cpp	Tue Aug 18 00:35:15 2015 +0100
@@ -6,8 +6,7 @@
  */
 
 
-#include "../../include/render.h"
-#include "../../include/RTAudio.h"	// to schedule lower prio parallel process
+#include <BeagleRT.h>	// to schedule lower prio parallel process
 #include <rtdk.h>
 #include <cmath>
 #include <stdio.h>
@@ -45,7 +44,7 @@
 extern float gCutFreq;
 
 
-// initialise_render() is called once before the audio rendering starts.
+// setup() 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.
 //
@@ -54,11 +53,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 setup(BeagleRTContext *context, void *userData)
 {
 
 	// Retrieve a parameter passed in from the initAudio() call
@@ -80,10 +75,9 @@
 // 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++) {
+	for(unsigned int n = 0; n < context->audioFrames; n++) {
 		float sample = 0;
 		float out = 0;
 
@@ -101,14 +95,14 @@
 		gLastY[1] = gLastY[0];
 		gLastY[0] = out;
 
-		for(int channel = 0; channel < gNumAudioChannels; channel++)
-			audioOut[n * gNumAudioChannels + channel] = out;	// ...and put it in both left and right channel
+		for(unsigned int channel = 0; channel < context->audioChannels; channel++)
+			context->audioOut[n * context->audioChannels + channel] = out;	// ...and put it in both left and right channel
 
 	}
 
 	// Request that the lower-priority tasks run at next opportunity
-	scheduleAuxiliaryTask(gChangeCoeffTask);
-	scheduleAuxiliaryTask(gInputTask);
+	BeagleRT_scheduleAuxiliaryTask(gChangeCoeffTask);
+	BeagleRT_scheduleAuxiliaryTask(gInputTask);
 }
 
 // First calculation of coefficients
@@ -145,10 +139,10 @@
 
 bool initialise_aux_tasks()
 {
-	if((gChangeCoeffTask = createAuxiliaryTaskLoop(&check_coeff, 90, "beaglert-check-coeff")) == 0)
+	if((gChangeCoeffTask = BeagleRT_createAuxiliaryTask(&check_coeff, 90, "beaglert-check-coeff")) == 0)
 		return false;
 
-	if((gInputTask = createAuxiliaryTaskLoop(&read_input, 50, "beaglert-read-input")) == 0)
+	if((gInputTask = BeagleRT_createAuxiliaryTask(&read_input, 50, "beaglert-read-input")) == 0)
 		return false;
 
 	rt_printf("Press 'a' to trigger sample, 's' to stop\n");
@@ -218,10 +212,10 @@
 
 
 
-// cleanup_render() is called once at the end, after the audio has stopped.
-// Release any resources that were allocated in initialise_render().
+// cleanup() is called once at the end, after the audio has stopped.
+// Release any resources that were allocated in setup().
 
-void cleanup_render()
+void cleanup(BeagleRTContext *context, void *userData)
 {
 	delete[] gSampleData.samples;
 }