Mercurial > hg > beaglert
diff projects/filter_IIR/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/filter_IIR/render.cpp Sat May 30 13:25:51 2015 -0500 +++ b/projects/filter_IIR/render.cpp Sun May 31 02:13:39 2015 -0500 @@ -6,8 +6,7 @@ */ -#include "../../include/render.h" -#include "../../include/RTAudio.h" // to schedule lower prio parallel process +#include "../../include/BeagleRT.h" // to schedule lower prio parallel process #include <rtdk.h> #include <cmath> #include <stdio.h> @@ -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 initialise_render(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"); @@ -221,7 +215,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) { delete[] gSampleData.samples; }