comparison examples/oscillator_bank/render.cpp @ 301:e4392164b458 prerelease

RENAMED BeagleRT to Bela AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, scripts probably not working
author Giulio Moro <giuliomoro@yahoo.it>
date Fri, 27 May 2016 14:34:41 +0100
parents dbeed520b014
children 421a69d42943
comparison
equal deleted inserted replaced
300:dbeed520b014 301:e4392164b458
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 <BeagleRT.h> 9 #include <Bela.h>
10 #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>
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 setup(BeagleRTContext *context, void *userData) 61 bool setup(BelaContext *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");
135 135
136 freq += increment; 136 freq += increment;
137 } 137 }
138 138
139 // Initialise auxiliary tasks 139 // Initialise auxiliary tasks
140 if((gFrequencyUpdateTask = BeagleRT_createAuxiliaryTask(&recalculate_frequencies, 85, "beaglert-update-frequencies")) == 0) 140 if((gFrequencyUpdateTask = Bela_createAuxiliaryTask(&recalculate_frequencies, 85, "beaglert-update-frequencies")) == 0)
141 return false; 141 return false;
142 142
143 //for(int n = 0; n < gNumOscillators; n++) 143 //for(int n = 0; n < gNumOscillators; n++)
144 // rt_printf("%f\n", gFrequencies[n]); 144 // rt_printf("%f\n", gFrequencies[n]);
145 145
152 // render() is called regularly at the highest priority by the audio engine. 152 // render() is called regularly at the highest priority by the audio engine.
153 // Input and output are given from the audio hardware and the other 153 // Input and output are given from the audio hardware and the other
154 // ADCs and DACs (if available). If only audio is available, numMatrixFrames 154 // ADCs and DACs (if available). If only audio is available, numMatrixFrames
155 // will be 0. 155 // will be 0.
156 156
157 void render(BeagleRTContext *context, void *userData) 157 void render(BelaContext *context, void *userData)
158 { 158 {
159 // Initialise buffer to 0 159 // Initialise buffer to 0
160 memset(context->audioOut, 0, 2 * context->audioFrames * sizeof(float)); 160 memset(context->audioOut, 0, 2 * context->audioFrames * sizeof(float));
161 161
162 // Render audio frames 162 // Render audio frames
177 gNewMaxFrequency = gNewMinFrequency; 177 gNewMaxFrequency = gNewMinFrequency;
178 gNewMinFrequency = temp; 178 gNewMinFrequency = temp;
179 } 179 }
180 180
181 // Request that the lower-priority task run at next opportunity 181 // Request that the lower-priority task run at next opportunity
182 //BeagleRT_scheduleAuxiliaryTask(gFrequencyUpdateTask); 182 //Bela_scheduleAuxiliaryTask(gFrequencyUpdateTask);
183 } 183 }
184 } 184 }
185 185
186 // This is a lower-priority call to update the frequencies which will happen 186 // This is a lower-priority call to update the frequencies which will happen
187 // periodically when the matrix is enabled. By placing it at a lower priority, 187 // periodically when the matrix is enabled. By placing it at a lower priority,
208 208
209 209
210 // cleanup() 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 setup(). 211 // Release any resources that were allocated in setup().
212 212
213 void cleanup(BeagleRTContext *context, void *userData) 213 void cleanup(BelaContext *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);