Mercurial > hg > beaglert
diff projects/audio_in_FFT/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 | ac8eb07afcf5 |
line wrap: on
line diff
--- a/projects/audio_in_FFT/render.cpp Mon Jun 08 01:07:48 2015 +0100 +++ b/projects/audio_in_FFT/render.cpp Tue Aug 18 00:35:15 2015 +0100 @@ -6,7 +6,7 @@ */ -#include "../../include/render.h" +#include <BeagleRT.h> #include <rtdk.h> #include <NE10.h> // neon library #include <cmath> @@ -23,7 +23,7 @@ ne10_fft_cpx_float32_t* frequencyDomain; ne10_fft_cfg_float32_t cfg; -// 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. // @@ -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 setup(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,16 +74,16 @@ gWritePointer = 0; } - for(int channel = 0; channel < gNumAudioChannels; channel++) - audioOut[n * gNumAudioChannels + channel] = (float) timeDomainOut[gWritePointer].r * gFFTScaleFactor; + for(unsigned int channel = 0; channel < context->audioChannels; channel++) + context->audioOut[n * context->audioChannels + channel] = (float) timeDomainOut[gWritePointer].r * gFFTScaleFactor; gWritePointer++; } } -// 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) { NE10_FREE(timeDomainIn); NE10_FREE(timeDomainOut);