Mercurial > hg > beaglert
diff projects/samples/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/samples/render.cpp Sat May 30 13:25:51 2015 -0500 +++ b/projects/samples/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> @@ -31,11 +30,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 @@ -55,10 +50,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(int n = 0; n < context->audioFrames; n++) { float out = 0; // If triggered... @@ -68,12 +62,12 @@ if(gReadPtr >= gSampleData.sampleLen) gReadPtr = -1; - for(int channel = 0; channel < gNumAudioChannels; channel++) - audioOut[n * gNumAudioChannels + channel] = out; // ...and put it in both left and right channel + for(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 task run at next opportunity - scheduleAuxiliaryTask(gTriggerSamplesTask); + BeagleRT_scheduleAuxiliaryTask(gTriggerSamplesTask); } // Initialise the auxiliary task @@ -81,7 +75,7 @@ bool initialise_trigger() { - if((gTriggerSamplesTask = createAuxiliaryTaskLoop(&trigger_samples, 50, "beaglert-trigger-samples")) == 0) + if((gTriggerSamplesTask = BeagleRT_createAuxiliaryTask(&trigger_samples, 50, "beaglert-trigger-samples")) == 0) return false; rt_printf("Press 'a' to trigger sample, 's' to stop\n"); @@ -127,7 +121,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; }