comparison examples/measure_noisefloor/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 <cmath> 11 #include <cmath>
12 12
13 int gBufferSize = 8192; 13 int gBufferSize = 8192;
14 14
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 setup(BeagleRTContext *context, void *userData) 35 bool setup(BelaContext *context, void *userData)
36 { 36 {
37 // Clear the filter data structures 37 // Clear the filter data structures
38 for(int i = 0; i < 10; i++) { 38 for(int i = 0; i < 10; i++) {
39 gReadBufferPointers[i] = gWriteBufferPointers[i] = 0; 39 gReadBufferPointers[i] = gWriteBufferPointers[i] = 0;
40 gBuffers0[i] = new float[gBufferSize]; 40 gBuffers0[i] = new float[gBufferSize];
45 rt_printf("Error allocating buffer %d\n", i); 45 rt_printf("Error allocating buffer %d\n", i);
46 return false; 46 return false;
47 } 47 }
48 } 48 }
49 49
50 gAnalysisTask = BeagleRT_createAuxiliaryTask(analyseResults, 50, "beaglert-analyse-results"); 50 gAnalysisTask = Bela_createAuxiliaryTask(analyseResults, 50, "beaglert-analyse-results");
51 51
52 return true; 52 return true;
53 } 53 }
54 54
55 // render() is called regularly at the highest priority by the audio engine. 55 // render() is called regularly at the highest priority by the audio engine.
56 // Input and output are given from the audio hardware and the other 56 // Input and output are given from the audio hardware and the other
57 // ADCs and DACs (if available). If only audio is available, numMatrixFrames 57 // ADCs and DACs (if available). If only audio is available, numMatrixFrames
58 // will be 0. 58 // will be 0.
59 59
60 void render(BeagleRTContext *context, void *userData) 60 void render(BelaContext *context, void *userData)
61 { 61 {
62 bool bufferIsFull = false; // Whether at least one buffer has filled 62 bool bufferIsFull = false; // Whether at least one buffer has filled
63 63
64 for(unsigned int n = 0; n < context->audioFrames; n++) { 64 for(unsigned int n = 0; n < context->audioFrames; n++) {
65 // Store audio inputs in buffer 65 // Store audio inputs in buffer
108 gReadBuffers[ch] = gBuffers0[ch]; 108 gReadBuffers[ch] = gBuffers0[ch];
109 gWriteBuffers[ch] = gBuffers1[ch]; 109 gWriteBuffers[ch] = gBuffers1[ch];
110 } 110 }
111 } 111 }
112 112
113 BeagleRT_scheduleAuxiliaryTask(gAnalysisTask); 113 Bela_scheduleAuxiliaryTask(gAnalysisTask);
114 } 114 }
115 } 115 }
116 116
117 void analyseResults() 117 void analyseResults()
118 { 118 {
152 } 152 }
153 153
154 // cleanup() is called once at the end, after the audio has stopped. 154 // cleanup() is called once at the end, after the audio has stopped.
155 // Release any resources that were allocated in setup(). 155 // Release any resources that were allocated in setup().
156 156
157 void cleanup(BeagleRTContext *context, void *userData) 157 void cleanup(BelaContext *context, void *userData)
158 { 158 {
159 for(int i = 0; i < 10; i++) { 159 for(int i = 0; i < 10; i++) {
160 delete gBuffers0[i]; 160 delete gBuffers0[i];
161 delete gBuffers1[i]; 161 delete gBuffers1[i];
162 } 162 }