comparison projects/oscillator_bank/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 "../../include/Utilities.h" 10 #include <Utilities.h>
11 #include <rtdk.h> 11 #include <rtdk.h>
12 #include <cstdlib> 12 #include <cstdlib>
13 #include <cmath> 13 #include <cmath>
14 #include <cstring> 14 #include <cstring>
15 #include <time.h> 15 #include <time.h>
32 // Task for handling the update of the frequencies using the matrix 32 // Task for handling the update of the frequencies using the matrix
33 AuxiliaryTask gFrequencyUpdateTask; 33 AuxiliaryTask gFrequencyUpdateTask;
34 34
35 // These settings are carried over from main.cpp 35 // These settings are carried over from main.cpp
36 // Setting global variables is an alternative approach 36 // Setting global variables is an alternative approach
37 // to passing a structure to userData in initialise_render() 37 // to passing a structure to userData in setup()
38 38
39 extern int gNumOscillators; 39 extern int gNumOscillators;
40 extern int gWavetableLength; 40 extern int gWavetableLength;
41 41
42 void recalculate_frequencies(); 42 void recalculate_frequencies();
48 float *phases, float *frequencies, float *amplitudes, 48 float *phases, float *frequencies, float *amplitudes,
49 float *freqDerivatives, float *ampDerivatives, 49 float *freqDerivatives, float *ampDerivatives,
50 float *lookupTable); 50 float *lookupTable);
51 } 51 }
52 52
53 // initialise_render() is called once before the audio rendering starts. 53 // setup() is called once before the audio rendering starts.
54 // Use it to perform any initialisation and allocation which is dependent 54 // Use it to perform any initialisation and allocation which is dependent
55 // on the period size or sample rate. 55 // on the period size or sample rate.
56 // 56 //
57 // userData holds an opaque pointer to a data structure that was passed 57 // userData holds an opaque pointer to a data structure that was passed
58 // in from the call to initAudio(). 58 // in from the call to initAudio().
59 // 59 //
60 // Return true on success; returning false halts the program. 60 // Return true on success; returning false halts the program.
61 bool initialise_render(BeagleRTContext *context, void *userData) 61 bool setup(BeagleRTContext *context, void *userData)
62 { 62 {
63 srandom(time(NULL)); 63 srandom(time(NULL));
64 64
65 if(context->audioChannels != 2) { 65 if(context->audioChannels != 2) {
66 rt_printf("Error: this example needs stereo audio enabled\n"); 66 rt_printf("Error: this example needs stereo audio enabled\n");
205 freq += increment; 205 freq += increment;
206 } 206 }
207 } 207 }
208 208
209 209
210 // cleanup_render() is called once at the end, after the audio has stopped. 210 // cleanup() is called once at the end, after the audio has stopped.
211 // Release any resources that were allocated in initialise_render(). 211 // Release any resources that were allocated in setup().
212 212
213 void cleanup_render(BeagleRTContext *context, void *userData) 213 void cleanup(BeagleRTContext *context, void *userData)
214 { 214 {
215 free(gWavetable); 215 free(gWavetable);
216 free(gPhases); 216 free(gPhases);
217 free(gFrequencies); 217 free(gFrequencies);
218 free(gAmplitudes); 218 free(gAmplitudes);