comparison examples/basic/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 1feb9c23ac57
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 <cmath> 10 #include <cmath>
11 #include <Utilities.h> 11 #include <Utilities.h>
12 12
13 float gFrequency = 440.0; 13 float gFrequency = 440.0;
14 float gPhase; 14 float gPhase;
21 // userData holds an opaque pointer to a data structure that was passed 21 // userData holds an opaque pointer to a data structure that was passed
22 // in from the call to initAudio(). 22 // in from the call to initAudio().
23 // 23 //
24 // Return true on success; returning false halts the program. 24 // Return true on success; returning false halts the program.
25 25
26 bool setup(BeagleRTContext *context, void *userData) 26 bool setup(BelaContext *context, void *userData)
27 { 27 {
28 // Retrieve a parameter passed in from the initAudio() call 28 // Retrieve a parameter passed in from the initAudio() call
29 if(userData != 0) 29 if(userData != 0)
30 gFrequency = *(float *)userData; 30 gFrequency = *(float *)userData;
31 31
38 // render() is called regularly at the highest priority by the audio engine. 38 // render() is called regularly at the highest priority by the audio engine.
39 // Input and output are given from the audio hardware and the other 39 // Input and output are given from the audio hardware and the other
40 // ADCs and DACs (if available). If only audio is available, numMatrixFrames 40 // ADCs and DACs (if available). If only audio is available, numMatrixFrames
41 // will be 0. 41 // will be 0.
42 42
43 void render(BeagleRTContext *context, void *userData) 43 void render(BelaContext *context, void *userData)
44 { 44 {
45 for(unsigned int n = 0; n < context->audioFrames; n++) { 45 for(unsigned int n = 0; n < context->audioFrames; n++) {
46 float out = 0.8f * sinf(gPhase); 46 float out = 0.8f * sinf(gPhase);
47 gPhase += 2.0 * M_PI * gFrequency * gInverseSampleRate; 47 gPhase += 2.0 * M_PI * gFrequency * gInverseSampleRate;
48 if(gPhase > 2.0 * M_PI) 48 if(gPhase > 2.0 * M_PI)
61 } 61 }
62 62
63 // cleanup() is called once at the end, after the audio has stopped. 63 // cleanup() is called once at the end, after the audio has stopped.
64 // Release any resources that were allocated in setup(). 64 // Release any resources that were allocated in setup().
65 65
66 void cleanup(BeagleRTContext *context, void *userData) 66 void cleanup(BelaContext *context, void *userData)
67 { 67 {
68 68
69 } 69 }