Mercurial > hg > beaglert
comparison examples/mpr121/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 |
---|---|
1 #include <BeagleRT.h> | 1 #include <Bela.h> |
2 #include <Utilities.h> | 2 #include <Utilities.h> |
3 #include <cmath> | 3 #include <cmath> |
4 #include <rtdk.h> | 4 #include <rtdk.h> |
5 #include "I2C_MPR121.h" | 5 #include "I2C_MPR121.h" |
6 | 6 |
45 // userData holds an opaque pointer to a data structure that was passed | 45 // userData holds an opaque pointer to a data structure that was passed |
46 // in from the call to initAudio(). | 46 // in from the call to initAudio(). |
47 // | 47 // |
48 // Return true on success; returning false halts the program. | 48 // Return true on success; returning false halts the program. |
49 | 49 |
50 bool setup(BeagleRTContext *context, void *userData) | 50 bool setup(BelaContext *context, void *userData) |
51 { | 51 { |
52 if(!mpr121.begin(1, 0x5A)) { | 52 if(!mpr121.begin(1, 0x5A)) { |
53 rt_printf("Error initialising MPR121\n"); | 53 rt_printf("Error initialising MPR121\n"); |
54 return false; | 54 return false; |
55 } | 55 } |
56 | 56 |
57 i2cTask = BeagleRT_createAuxiliaryTask(readMPR121, 50, "beaglert-mpr121"); | 57 i2cTask = Bela_createAuxiliaryTask(readMPR121, 50, "beaglert-mpr121"); |
58 readIntervalSamples = context->audioSampleRate / readInterval; | 58 readIntervalSamples = context->audioSampleRate / readInterval; |
59 | 59 |
60 for(int i = 0; i < NUM_TOUCH_PINS; i++) { | 60 for(int i = 0; i < NUM_TOUCH_PINS; i++) { |
61 gNormFrequencies[i] = 2.0 * M_PI * gFrequencies[i] / context->audioSampleRate; | 61 gNormFrequencies[i] = 2.0 * M_PI * gFrequencies[i] / context->audioSampleRate; |
62 } | 62 } |
67 // render() is called regularly at the highest priority by the audio engine. | 67 // render() is called regularly at the highest priority by the audio engine. |
68 // Input and output are given from the audio hardware and the other | 68 // Input and output are given from the audio hardware and the other |
69 // ADCs and DACs (if available). If only audio is available, numAnalogFrames | 69 // ADCs and DACs (if available). If only audio is available, numAnalogFrames |
70 // will be 0. | 70 // will be 0. |
71 | 71 |
72 void render(BeagleRTContext *context, void *userData) | 72 void render(BelaContext *context, void *userData) |
73 { | 73 { |
74 for(int n = 0; n < context->audioFrames; n++) { | 74 for(int n = 0; n < context->audioFrames; n++) { |
75 // Keep this code: it schedules the touch sensor readings | 75 // Keep this code: it schedules the touch sensor readings |
76 if(++readCount >= readIntervalSamples) { | 76 if(++readCount >= readIntervalSamples) { |
77 readCount = 0; | 77 readCount = 0; |
78 BeagleRT_scheduleAuxiliaryTask(i2cTask); | 78 Bela_scheduleAuxiliaryTask(i2cTask); |
79 } | 79 } |
80 | 80 |
81 float sample = 0.0; | 81 float sample = 0.0; |
82 | 82 |
83 // This code can be replaced with your favourite audio code | 83 // This code can be replaced with your favourite audio code |
100 } | 100 } |
101 | 101 |
102 // cleanup() is called once at the end, after the audio has stopped. | 102 // cleanup() is called once at the end, after the audio has stopped. |
103 // Release any resources that were allocated in setup(). | 103 // Release any resources that were allocated in setup(). |
104 | 104 |
105 void cleanup(BeagleRTContext *context, void *userData) | 105 void cleanup(BelaContext *context, void *userData) |
106 { | 106 { |
107 // Nothing to do here | 107 // Nothing to do here |
108 } | 108 } |
109 | 109 |
110 | 110 |