Mercurial > hg > beaglert
comparison examples/level_meter/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 <Utilities.h> | 10 #include <Utilities.h> |
11 #include <cmath> | 11 #include <cmath> |
12 | 12 |
13 #define NUMBER_OF_SEGMENTS 10 | 13 #define NUMBER_OF_SEGMENTS 10 |
14 | 14 |
41 // userData holds an opaque pointer to a data structure that was passed | 41 // userData holds an opaque pointer to a data structure that was passed |
42 // in from the call to initAudio(). | 42 // in from the call to initAudio(). |
43 // | 43 // |
44 // Return true on success; returning false halts the program. | 44 // Return true on success; returning false halts the program. |
45 | 45 |
46 bool setup(BeagleRTContext *context, void *userData) | 46 bool setup(BelaContext *context, void *userData) |
47 { | 47 { |
48 // This project makes the assumption that the audio and digital | 48 // This project makes the assumption that the audio and digital |
49 // sample rates are the same. But check it to be sure! | 49 // sample rates are the same. But check it to be sure! |
50 if(context->audioFrames != context->digitalFrames) { | 50 if(context->audioFrames != context->digitalFrames) { |
51 rt_printf("Error: this project needs the audio and digital sample rates to be the same.\n"); | 51 rt_printf("Error: this project needs the audio and digital sample rates to be the same.\n"); |
69 // render() is called regularly at the highest priority by the audio engine. | 69 // render() is called regularly at the highest priority by the audio engine. |
70 // Input and output are given from the audio hardware and the other | 70 // Input and output are given from the audio hardware and the other |
71 // ADCs and DACs (if available). If only audio is available, numMatrixFrames | 71 // ADCs and DACs (if available). If only audio is available, numMatrixFrames |
72 // will be 0. | 72 // will be 0. |
73 | 73 |
74 void render(BeagleRTContext *context, void *userData) | 74 void render(BelaContext *context, void *userData) |
75 { | 75 { |
76 for(unsigned int n = 0; n < context->audioFrames; n++) { | 76 for(unsigned int n = 0; n < context->audioFrames; n++) { |
77 // Get average of audio input channels | 77 // Get average of audio input channels |
78 float sample = 0; | 78 float sample = 0; |
79 for(unsigned int ch = 0; ch < context->audioChannels; ch++) { | 79 for(unsigned int ch = 0; ch < context->audioChannels; ch++) { |
132 } | 132 } |
133 | 133 |
134 // cleanup() is called once at the end, after the audio has stopped. | 134 // cleanup() is called once at the end, after the audio has stopped. |
135 // Release any resources that were allocated in setup(). | 135 // Release any resources that were allocated in setup(). |
136 | 136 |
137 void cleanup(BeagleRTContext *context, void *userData) | 137 void cleanup(BelaContext *context, void *userData) |
138 { | 138 { |
139 | 139 |
140 } | 140 } |