Mercurial > hg > beaglert
comparison examples/samples/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: Andrew McPherson and Victor Zappi | 5 * Author: Andrew McPherson and Victor Zappi |
6 */ | 6 */ |
7 | 7 |
8 | 8 |
9 #include <BeagleRT.h> | 9 #include <Bela.h> |
10 #include <cmath> | 10 #include <cmath> |
11 #include "SampleData.h" | 11 #include "SampleData.h" |
12 | 12 |
13 SampleData gSampleData; // User defined structure to get complex data from main | 13 SampleData gSampleData; // User defined structure to get complex data from main |
14 int gReadPtr; // Position of last read sample from file | 14 int gReadPtr; // Position of last read sample from file |
26 // userData holds an opaque pointer to a data structure that was passed | 26 // userData holds an opaque pointer to a data structure that was passed |
27 // in from the call to initAudio(). | 27 // in from the call to initAudio(). |
28 // | 28 // |
29 // Return true on success; returning false halts the program. | 29 // Return true on success; returning false halts the program. |
30 | 30 |
31 bool setup(BeagleRTContext *context, void *userData) | 31 bool setup(BelaContext *context, void *userData) |
32 { | 32 { |
33 | 33 |
34 // Retrieve a parameter passed in from the initAudio() call | 34 // Retrieve a parameter passed in from the initAudio() call |
35 gSampleData = *(SampleData *)userData; | 35 gSampleData = *(SampleData *)userData; |
36 | 36 |
46 // render() is called regularly at the highest priority by the audio engine. | 46 // render() is called regularly at the highest priority by the audio engine. |
47 // Input and output are given from the audio hardware and the other | 47 // Input and output are given from the audio hardware and the other |
48 // ADCs and DACs (if available). If only audio is available, numMatrixFrames | 48 // ADCs and DACs (if available). If only audio is available, numMatrixFrames |
49 // will be 0. | 49 // will be 0. |
50 | 50 |
51 void render(BeagleRTContext *context, void *userData) | 51 void render(BelaContext *context, void *userData) |
52 { | 52 { |
53 for(unsigned int n = 0; n < context->audioFrames; n++) { | 53 for(unsigned int n = 0; n < context->audioFrames; n++) { |
54 float out = 0; | 54 float out = 0; |
55 | 55 |
56 // If triggered... | 56 // If triggered... |
63 for(unsigned int channel = 0; channel < context->audioChannels; channel++) | 63 for(unsigned int channel = 0; channel < context->audioChannels; channel++) |
64 context->audioOut[n * context->audioChannels + channel] = out; // ...and put it in both left and right channel | 64 context->audioOut[n * context->audioChannels + channel] = out; // ...and put it in both left and right channel |
65 } | 65 } |
66 | 66 |
67 // Request that the lower-priority task run at next opportunity | 67 // Request that the lower-priority task run at next opportunity |
68 BeagleRT_scheduleAuxiliaryTask(gTriggerSamplesTask); | 68 Bela_scheduleAuxiliaryTask(gTriggerSamplesTask); |
69 } | 69 } |
70 | 70 |
71 // Initialise the auxiliary task | 71 // Initialise the auxiliary task |
72 // and print info | 72 // and print info |
73 | 73 |
74 bool initialise_trigger() | 74 bool initialise_trigger() |
75 { | 75 { |
76 if((gTriggerSamplesTask = BeagleRT_createAuxiliaryTask(&trigger_samples, 50, "beaglert-trigger-samples")) == 0) | 76 if((gTriggerSamplesTask = Bela_createAuxiliaryTask(&trigger_samples, 50, "beaglert-trigger-samples")) == 0) |
77 return false; | 77 return false; |
78 | 78 |
79 rt_printf("Press 'a' to trigger sample, 's' to stop\n"); | 79 rt_printf("Press 'a' to trigger sample, 's' to stop\n"); |
80 rt_printf("Press 'q' to quit\n"); | 80 rt_printf("Press 'q' to quit\n"); |
81 | 81 |
117 | 117 |
118 | 118 |
119 // cleanup() is called once at the end, after the audio has stopped. | 119 // cleanup() is called once at the end, after the audio has stopped. |
120 // Release any resources that were allocated in setup(). | 120 // Release any resources that were allocated in setup(). |
121 | 121 |
122 void cleanup(BeagleRTContext *context, void *userData) | 122 void cleanup(BelaContext *context, void *userData) |
123 { | 123 { |
124 delete[] gSampleData.samples; | 124 delete[] gSampleData.samples; |
125 } | 125 } |