Mercurial > hg > beaglert
comparison examples/filter_IIR/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> // to schedule lower prio parallel process | 9 #include <Bela.h> // to schedule lower prio parallel process |
10 #include <rtdk.h> | 10 #include <rtdk.h> |
11 #include <cmath> | 11 #include <cmath> |
12 #include <stdio.h> | 12 #include <stdio.h> |
13 #include "SampleData.h" | 13 #include "SampleData.h" |
14 | 14 |
51 // userData holds an opaque pointer to a data structure that was passed | 51 // userData holds an opaque pointer to a data structure that was passed |
52 // in from the call to initAudio(). | 52 // in from the call to initAudio(). |
53 // | 53 // |
54 // Return true on success; returning false halts the program. | 54 // Return true on success; returning false halts the program. |
55 | 55 |
56 bool setup(BeagleRTContext *context, void *userData) | 56 bool setup(BelaContext *context, void *userData) |
57 { | 57 { |
58 | 58 |
59 // Retrieve a parameter passed in from the initAudio() call | 59 // Retrieve a parameter passed in from the initAudio() call |
60 gSampleData = *(SampleData *)userData; | 60 gSampleData = *(SampleData *)userData; |
61 | 61 |
73 // render() is called regularly at the highest priority by the audio engine. | 73 // render() is called regularly at the highest priority by the audio engine. |
74 // Input and output are given from the audio hardware and the other | 74 // Input and output are given from the audio hardware and the other |
75 // ADCs and DACs (if available). If only audio is available, numMatrixFrames | 75 // ADCs and DACs (if available). If only audio is available, numMatrixFrames |
76 // will be 0. | 76 // will be 0. |
77 | 77 |
78 void render(BeagleRTContext *context, void *userData) | 78 void render(BelaContext *context, void *userData) |
79 { | 79 { |
80 for(unsigned int n = 0; n < context->audioFrames; n++) { | 80 for(unsigned int n = 0; n < context->audioFrames; n++) { |
81 float sample = 0; | 81 float sample = 0; |
82 float out = 0; | 82 float out = 0; |
83 | 83 |
99 context->audioOut[n * context->audioChannels + channel] = out; // ...and put it in both left and right channel | 99 context->audioOut[n * context->audioChannels + channel] = out; // ...and put it in both left and right channel |
100 | 100 |
101 } | 101 } |
102 | 102 |
103 // Request that the lower-priority tasks run at next opportunity | 103 // Request that the lower-priority tasks run at next opportunity |
104 BeagleRT_scheduleAuxiliaryTask(gChangeCoeffTask); | 104 Bela_scheduleAuxiliaryTask(gChangeCoeffTask); |
105 BeagleRT_scheduleAuxiliaryTask(gInputTask); | 105 Bela_scheduleAuxiliaryTask(gInputTask); |
106 } | 106 } |
107 | 107 |
108 // First calculation of coefficients | 108 // First calculation of coefficients |
109 | 109 |
110 void initialise_filter(float freq) | 110 void initialise_filter(float freq) |
137 // Initialise the auxiliary tasks | 137 // Initialise the auxiliary tasks |
138 // and print info | 138 // and print info |
139 | 139 |
140 bool initialise_aux_tasks() | 140 bool initialise_aux_tasks() |
141 { | 141 { |
142 if((gChangeCoeffTask = BeagleRT_createAuxiliaryTask(&check_coeff, 90, "beaglert-check-coeff")) == 0) | 142 if((gChangeCoeffTask = Bela_createAuxiliaryTask(&check_coeff, 90, "beaglert-check-coeff")) == 0) |
143 return false; | 143 return false; |
144 | 144 |
145 if((gInputTask = BeagleRT_createAuxiliaryTask(&read_input, 50, "beaglert-read-input")) == 0) | 145 if((gInputTask = Bela_createAuxiliaryTask(&read_input, 50, "beaglert-read-input")) == 0) |
146 return false; | 146 return false; |
147 | 147 |
148 rt_printf("Press 'a' to trigger sample, 's' to stop\n"); | 148 rt_printf("Press 'a' to trigger sample, 's' to stop\n"); |
149 rt_printf("Press 'z' to low down cut-off freq of 100 Hz, 'x' to raise it up\n"); | 149 rt_printf("Press 'z' to low down cut-off freq of 100 Hz, 'x' to raise it up\n"); |
150 rt_printf("Press 'q' to quit\n"); | 150 rt_printf("Press 'q' to quit\n"); |
213 | 213 |
214 | 214 |
215 // cleanup() is called once at the end, after the audio has stopped. | 215 // cleanup() is called once at the end, after the audio has stopped. |
216 // Release any resources that were allocated in setup(). | 216 // Release any resources that were allocated in setup(). |
217 | 217 |
218 void cleanup(BeagleRTContext *context, void *userData) | 218 void cleanup(BelaContext *context, void *userData) |
219 { | 219 { |
220 delete[] gSampleData.samples; | 220 delete[] gSampleData.samples; |
221 } | 221 } |