comparison projects/audio_in_FFT/render.cpp @ 56:3c3a1357657d newapi

Further API update to name three primary functions setup(), render() and cleanup(). Changed include paths so now can #include <BeagleRT.h>. Removed stale pru_rtaudio.bin file as this is now done as pru_rtaudio_bin.h. Updated examples to new API and fixed minor compiler warnings along the way. Network example needs further attention to compile.
author andrewm
date Wed, 15 Jul 2015 12:10:51 +0100
parents a6d223473ea2
children ac8eb07afcf5
comparison
equal deleted inserted replaced
55:41d24dba6b74 56:3c3a1357657d
4 * Created on: Oct 24, 2014 4 * Created on: Oct 24, 2014
5 * Author: parallels 5 * Author: parallels
6 */ 6 */
7 7
8 8
9 #include "../../include/BeagleRT.h" 9 #include <BeagleRT.h>
10 #include <rtdk.h> 10 #include <rtdk.h>
11 #include <NE10.h> // neon library 11 #include <NE10.h> // neon library
12 #include <cmath> 12 #include <cmath>
13 13
14 int gFFTSize; 14 int gFFTSize;
21 ne10_fft_cpx_float32_t* timeDomainIn; 21 ne10_fft_cpx_float32_t* timeDomainIn;
22 ne10_fft_cpx_float32_t* timeDomainOut; 22 ne10_fft_cpx_float32_t* timeDomainOut;
23 ne10_fft_cpx_float32_t* frequencyDomain; 23 ne10_fft_cpx_float32_t* frequencyDomain;
24 ne10_fft_cfg_float32_t cfg; 24 ne10_fft_cfg_float32_t cfg;
25 25
26 // initialise_render() is called once before the audio rendering starts. 26 // setup() is called once before the audio rendering starts.
27 // Use it to perform any initialisation and allocation which is dependent 27 // Use it to perform any initialisation and allocation which is dependent
28 // on the period size or sample rate. 28 // on the period size or sample rate.
29 // 29 //
30 // userData holds an opaque pointer to a data structure that was passed 30 // userData holds an opaque pointer to a data structure that was passed
31 // in from the call to initAudio(). 31 // in from the call to initAudio().
32 // 32 //
33 // Return true on success; returning false halts the program. 33 // Return true on success; returning false halts the program.
34 34
35 bool initialise_render(BeagleRTContext *context, void *userData) 35 bool setup(BeagleRTContext *context, void *userData)
36 { 36 {
37 // Retrieve a parameter passed in from the initAudio() call 37 // Retrieve a parameter passed in from the initAudio() call
38 gFFTSize = *(int *)userData; 38 gFFTSize = *(int *)userData;
39 gFFTScaleFactor = 1.0f / (float)gFFTSize; 39 gFFTScaleFactor = 1.0f / (float)gFFTSize;
40 40
72 72
73 gReadPointer = 0; 73 gReadPointer = 0;
74 gWritePointer = 0; 74 gWritePointer = 0;
75 } 75 }
76 76
77 for(int channel = 0; channel < context->audioChannels; channel++) 77 for(unsigned int channel = 0; channel < context->audioChannels; channel++)
78 context->audioOut[n * context->audioChannels + channel] = (float) timeDomainOut[gWritePointer].r * gFFTScaleFactor; 78 context->audioOut[n * context->audioChannels + channel] = (float) timeDomainOut[gWritePointer].r * gFFTScaleFactor;
79 gWritePointer++; 79 gWritePointer++;
80 } 80 }
81 } 81 }
82 82
83 // cleanup_render() is called once at the end, after the audio has stopped. 83 // cleanup() is called once at the end, after the audio has stopped.
84 // Release any resources that were allocated in initialise_render(). 84 // Release any resources that were allocated in setup().
85 85
86 void cleanup_render(BeagleRTContext *context, void *userData) 86 void cleanup(BeagleRTContext *context, void *userData)
87 { 87 {
88 NE10_FREE(timeDomainIn); 88 NE10_FREE(timeDomainIn);
89 NE10_FREE(timeDomainOut); 89 NE10_FREE(timeDomainOut);
90 NE10_FREE(frequencyDomain); 90 NE10_FREE(frequencyDomain);
91 NE10_FREE(cfg); 91 NE10_FREE(cfg);