comparison examples/audio_in_FFT/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 db2fe4e1b88e
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 <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;
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 // 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
51 // render() is called regularly at the highest priority by the audio engine. 51 // render() is called regularly at the highest priority by the audio engine.
52 // Input and output are given from the audio hardware and the other 52 // Input and output are given from the audio hardware and the other
53 // ADCs and DACs (if available). If only audio is available, numMatrixFrames 53 // ADCs and DACs (if available). If only audio is available, numMatrixFrames
54 // will be 0. 54 // will be 0.
55 55
56 void render(BeagleRTContext *context, void *userData) 56 void render(BelaContext *context, void *userData)
57 { 57 {
58 for(unsigned int n = 0; n < context->audioFrames; n++) { 58 for(unsigned int n = 0; n < context->audioFrames; n++) {
59 timeDomainIn[gReadPointer].r = (ne10_float32_t) ((context->audioIn[n*context->audioChannels] + 59 timeDomainIn[gReadPointer].r = (ne10_float32_t) ((context->audioIn[n*context->audioChannels] +
60 context->audioIn[n*context->audioChannels+1]) * 0.5); 60 context->audioIn[n*context->audioChannels+1]) * 0.5);
61 timeDomainIn[gReadPointer].i = 0; 61 timeDomainIn[gReadPointer].i = 0;
81 } 81 }
82 82
83 // cleanup() 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 setup(). 84 // Release any resources that were allocated in setup().
85 85
86 void cleanup(BeagleRTContext *context, void *userData) 86 void cleanup(BelaContext *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);